• I’m trying to display custom post type titles in my theme. This screenshot from Justin Tadlock’s site best shows what I’d like to do. If you notice he has the custom post type title displaying in grey before the title of that specific post. I was wondering how I would do this? Also how would I style it?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mediadecay

    (@mediadecay)

    I’ve discovered partially how to do this. I can now display everything using this:

    <?php $post_type = get_post_type_object( get_post_type($post) );
    echo $post_type->label ; ?>

    but it displays all post type names including the standard “post” so a custom post type of “Movie” and title of “Scott Pilgrim” will display as
    Movie Scott Pilgrim but a regular post with the default post type “post” with a title of “Hello World!” will also display as Post Hello World!, how do I exclude posts from displaying “Post” before their title?

    Thread Starter mediadecay

    (@mediadecay)

    Well I solved this problem thanks to Mr. Tadlock himself. gave me the code he used so it would be something like this if anyone else is trying to accomplish the same task:

    <?php
    
    $type = get_post_type();
    
    if ( 'movie' == $type )
    	echo 'Movie: ';
    elseif ( 'book' == $type )
    	echo 'Book: ';
    
    ?>

    Hello mediadecay,
    This is the only code you used?
    I’m trying to use the plugin ‘Custom Post Type UI’ to display (meta)data just like your Movie: ‘Name of movie’ example. I can’t seem to display any of the data in my posts at all (except for the standard post title and content of course)
    Where did you put the code? I have created a separate template page named ‘page-movies.php’ (for this test), Should i put it in there?
    Doesn’t work the way i do it anyway.
    Help’s appreciated.

    Thread Starter mediadecay

    (@mediadecay)

    I used this for both my single-movies template as well as my index.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Displaying custom post titles?’ is closed to new replies.