« Masalah Kompatibilitas Postnuke 0.764 dengan PHP 5.2.*Urutan Traffic Rank 5 Situs Partai Menjelang Pemilu 2009 »

Accomodating WP-PostViews and WP-PostRatings plugins to Popular Post Plugin (Wordpress)

11-05-2009

Permalink 16:24:48, by hendra Email , 208 words, 2580 views   Indonesia
Categories: Programming

Accomodating WP-PostViews and WP-PostRatings plugins to Popular Post Plugin (Wordpress)

I want to use a Wordpress plugin named: Popular Posts plugin (by Rob Marsh, SJ) . This plugin using 'pvc_views' metadata as an order in SQL query. With this plugin, I want to accomodate 'views' metadata (from WP-PostViews plugin) and 'ratings_score' metadata (from WP-PostRatings plugin) plugins too, instead of 'pvc_views' metadata. So I changed the source code, here they are:

— FILE: popular-posts.php (Version: 2.6.2.0) —

Find this :

$where[] = "meta_key = 'pvc_views'";

and then I changed with this:


if ($options['popular_mode'] == 'ratings_score') {
$where[] = "meta_key = 'ratings_score'"; //from plugin WP-PostRatings
} elseif ($options['popular_mode'] == 'views') {
$where[] = "meta_key = 'views'"; //from plugin WP-PostViews
} else
{
$where[] = "meta_key = 'pvc_views'"; //default;
}

— END OF FILE: popular-posts.php —

# New parameter:

- popular_mode:

  • views, if you want to use views metadata (from wp-postviews). 
  • ratings_score, if you want to use ratings_score metadata (from wp-postratings). 
  • if popular_mode not defined, the default is using pvc_views metadata.

How to use:

To use wp-postviews as an order criteria, use this:

popular_posts('[.....]&popular_mode=views');

To use wp-postratings as an order criteria, use this:

popular_posts('[.....]&popular_mode=ratings_score');

Thank you. :)

NB: sorry if my English grammar is bad.

Trackback address for this post

This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

1 comment

Comment from: Adam Capriola [Visitor] · http://adamcapriola.com
Nice guide, but I am a little confused.

1. What does the [.....] mean? Where do I put that code?

2. How can I change the {postviews} output tag to show the WP-PostViews count too?

Thanks so much!

-Adam
10-02-2010 @ 23:36

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)
Mudah-mudahan bermanfaat.
[Kritik dan Saran]

Search

XML Feeds










powered by b2evolution free blog software