• ionurboz

    (@ionurboz)


    How to get post type data in the archive page?

    I want post_type slug add class name body. For fallback on the css!

    post_type_archive_title('',false)
    It return current archive post type (Title)!

    function post_type_slug(){
    	$post_type = get_post_type();
    	if ( $post_type )
    	{
    	    $post_type_data = get_post_type_object( $post_type );
    	    $post_type_slug = $post_type_data->rewrite['slug'];
    	    return $post_type_slug;
    	}
    	else
    		return false;
    }

    It work just current post type archive page have while post!
    If archive is empty return ” ”

Viewing 1 replies (of 1 total)
  • Thread Starter ionurboz

    (@ionurboz)

    workaround:

    function post_type_slug(){
    	$post_type = get_post_type();
    	if ( $post_type )
    	{
    	    $post_type_data = get_post_type_object( $post_type );
    	    $post_type_slug = $post_type_data->rewrite['slug'];
    	    return $post_type_slug;
    	}
    	else{
    
    		$post_type_archive_title = post_type_archive_title('',false);
    		if($post_type_archive_title=='The Bykus')
    		return 'thebykus';
    		else return false;
    	}
    }
Viewing 1 replies (of 1 total)

The topic ‘WordPress custom post type data…’ is closed to new replies.