Support » Fixing WordPress » display custom post types.. please help!

  • I am sure this is really simple but I just cant work it out so if someone can help me would be amazingly grateful! Pretty new to this. Thanks.


    I have created a post type called ‘comedy’ which has taxonomies of ‘comedian’, ‘venue’ and ‘price’ using the custom post type UI plugin. I have then created a single post template for this called single-comedy.php to display the comedy custom posts. To test that the comedy post type was diverting to the single-comedy.php template I put this in there: <p>This is the template single-comedy.php</p>. You can see this here so it is definitely using that template

    What I am trying to do is display the ‘comedian’, ‘venue’ and ‘price’ meta info in the post. I have included <?php the_meta(); ?> in the single-comedy.php template directly below
    <?php get_template_part( ‘content’, ‘single’ ); ?>template
    but it is not displaying the custom meta.

    I tested on a normal post putting in the standard custom fields section on a post and it shows correctly. I edited single.php and entered <?php the_meta(); ?> and it shows the custom meta info on the post. You can see this here

    So what I need to know is am I going about this the right way by creating a new post template called single-comedy.php and if so what code do i need to enter to display the custom fields that are generated by the custom post type UI plugin.

    Thank you in advance for any help..

Viewing 8 replies - 1 through 8 (of 8 total)
  • Is the custom data really a taxonomy? It sounds like it’ll be more likely using some form of get_post_custom.

    Try adding this to your template to see what the output, if any, is:

    $custom = get_post_custom($post->ID);

    BTW I’m assuming this is within a regular loop where the post is $post…

    Hi SpankMarvin, thanks for replying.

    I entered this into the post template:

    <?php $custom = get_post_custom($post->ID);
    print_r($custom); ?>

    you can see the output here:

    Sorry, really not to sure what you mean by – assuming this is within a regular loop where the post is $post…
    It is within the loop as far as I know.

    Hmm, doesn’t look like there’s any other custom data using that function, then. I’m sorry, not sure what else to suggest…

    Ah shucks, thanks for trying though Spank. This has been bugging me for days.

    The custom post type UI plugin is so simple to setup but i just cannot work out how to display the custom fields in a post. It is really easy to display the standard custom fields that wordpress provides that is explained here but I just cannot display the info from the custom post type UI plugin.

    Anyone..? Someone must be using this plugin and displaying the info on their posts. Help out a noob would ya..

    Not sure about how the plugin asks you to define the custom fields, but I guess it’d be worth trying:

    $venue = get_post_meta($post->ID, "venue", true);

    And seeing whether that spits out anything useful?

    no output from that I’m afraid mate.

    I find lots of articles that tell you really well how to create custom post types but no one really goes into detail on how to display the fields in a post. eg/

    I reckon a well written post on the subject would get a lot of love..

    Well, the conventional way OUGHT to be to use the get_post_custom() function. This works by saying something like $custom = get_post_custom($post->ID); and then calling, say, $venue = $custom[‘venue’][0]; to retrieve a field with the name attribute of “venue”.

    However, unless I’m missing something, the plugin you are using must be storing these extra fields some other way…

    gona get a friend to have a look tomorrow hopefully. If I can come up with an answer will let you know.
    Thanks for your help Spank, is much appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘display custom post types.. please help!’ is closed to new replies.