Forums

[resolved] displaying key/value on posts only in a certain category while on posts page (3 posts)

  1. Maxaud
    Member
    Posted 4 years ago #

    Hello,
    I'm designing a site for a friend where he can submit featured listings (he's a realtor) and they get put into a featured listings category. I'm using keys/values for him to define stuff like price, locations, acres, etc. and would like to display this info on the individual posts pages.

    I've tried editing single.php and if I enter the code (this code for each different key/value):
    <?php $key="List Price"; $value =get_post_meta($post->ID, $key, true); echo "Price: $".$value; ?> <br />
    It shows up how I'd like it to but at the same time it adds the "Price:" text to EVERY post in the site (Not all posts are featured listings posts).

    I've also used the_meta() and that seems to work though I'd like for it not to be in alphabetical order and I'd like to have more control over it.

    Is there any fixes for this?
    I've tried everything I could find.

  2. moshu
    Member
    Posted 4 years ago #

    (Not all posts are featured listings posts)
    Does that mean those posts are in another category?
    In that case you may want to try a plugin called post-templates by category, which gives you the possibility to use different single templates for diff cats.
    http://guff.szub.net/2005/07/21/post-templates-by-category/

  3. Maxaud
    Member
    Posted 4 years ago #

    crazy, I just tried (without reading your reply) that and it works great.

    Was just coming to mark this as resolved with my fix.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic