treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress Custom Fields & Image URLs

  • Alright! Here's what I am trying to do...

    I am working on a Wordpress site based on game reviews. The friend I am doing the site for requested the option to add rating stars to represent their opinion of the game. What I did was create 5 png images that could be included in the post for whichever rating they wanted (3-star.png ect.) That currently works fine if they put in the entire url of the image. I want this to be a bit more simple so I was wondering if there is a way that I could do something like...


    <div class=\"ratewrap\">

    <?php $postimageurl = get_post_meta($post->ID, 'rating', true); if ($postimageurl) { ?>

    <img src=\"http://domain.com/wp-content/themes/mytheme/images/<?php echo $postimageurl; ?>.png\" alt=\"\" width=\"156\" />

    <?php } ?>

    </div>


    With this idea they would only have to type in the image name '3-star' instead of 'http://domain.com/wp-content/themes/mytheme/images/s-star.png'. I'm a total newbie to custom fields and PHP :)


    I hope that makes sense.

    Thanks
  • Check out Star Rating for Reviews plug-in for Wordpress. Install and activate the plugin then all you need to do is add

    [Rating:3.5]


    to your post to get a 5-star rating appear.
  • Cool! Thanks, davesgonebananas! :) I tried looking for a plugin that wasn't for public rating and had no luck. I'll give this a shot.