[wp-hackers] Rating system.

Scott Reilly coffee2code at scottreilly.net
Wed Aug 4 00:59:13 UTC 2004


Here's how I'd do it.  Naturally, being me, I'd use my Get Custom Field Values 
plugin...
http://www.coffee2code.com/archives/2004/06/30/plugin-get-custom/

In index.php, after <?php the_content(); ?>, add this:

<?php get_custom('rating','Rating: <span class="rating"><img alt="rating" 
src="/wp-content/images/rating', '.png" /></span>'); ?>

In the Advanced Post editing page, add a custom field key called 'rating'.  
Then whenever you make a post that needs to have the ratings image, select 
the field from the custom field dropdown and give it a value of whatever... 
(i'll assume some number between 1 - 5).

So assuming you had a rating of 4, the result on your main page would be:

Rating: <span class="rating"><img alt="rating" 
src="/wp-content/images/rating4.png /></span>

With my example, if you don't give the post a rating, nothing will display.  
If you wanted a non-rating image, you could have added it as another arg (see 
plugin documentation if you are interested).  I'm sure you'd want to 
customize that rather simple example.

-Scott
http://www.coffee2code.com


On Tuesday 03 August 2004 08:01 pm, Craig Hartel wrote:
> Thanks for the suggestion, Alex. Um, just as a qualifier, I know how to
> spell "PHP" and that's about it. :)
>
> Craig.
>
> Alex King wrote:
> > I'd use custom fields for this.
> >
> > --Alex
> >
> > http://www.alexking.org/



More information about the hackers mailing list