• HI,
    2 quick questions.

    1. Is it possible to omit certain posts from being registered by WP Popular Posts?

    2. I need to update the plugin manually. Will i loose the accumulated data on the posts popularity?

    thanks a lot!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi jimjamming,

    1. You’d need to hack my plugin to do that, but yes it is possible. For pages that WPP has not registered yet:

    # Find the function update_mostpopular (line 284 on wordpress-popular-posts.php)

    # Below “$postid = $wp_query->post->ID; // get post ID” (line 289), add this code:

    $exclude = array(1,2,3); // the id’s of the posts you wish to exclude (separated by comma)
    if (in_array($postid, $exclude)) return $content;

    For pages that WPP has already registered, but that you want to exclude from the listing:

    # Find “$mostpopular = $wpdb->get_results” (line 162)

    # Right after $nopages, add ” AND $wpdb->posts.ID NOT IN(1,2,3) ” (without quotes).

    2. No, you won’t lose any data so don’t worry.

    Along the same lines as question 1, is there a way to have this ignore certain post categories?

    That’d require a more complex sql query, onedeep. I’ll try a few different ideas and get back to you once I get a solution that won’t require an extensive use of the database.

    Thread Starter jimjamming

    (@jimjamming)

    Thanks for the replies. Much appreciated.

    Hi Ikki24,

    any news on excluding categories? I could really use this possibility

    Thanks!

    Hi Ikki24 and taeke,

    any news on excluding categories? I could really use this possibility

    Thanks!

    Hi guys,

    Sorry for not replying earlier. Unfortunately, I haven’t been able to work on my plugin for some time due to some personal issues. I’ve been testing a few ideas but none of them work as expected or use a lot of server resources – and that’s not good.

    Will get back to the design table as soon as I get some spare time, so don’t worry!

    to exclude categories, this is what I did:

    first, find the line
    $mostpopular = $wpdb->get_results

    then i changed it to this:

    /* Exclude certain categories from Popular Posts results */
    			$excludeCats = " AND wp_posts.ID NOT IN (SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (17)) ";
    
    			$mpQuery = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title $fields FROM $wpdb->posts LEFT JOIN $table_wpp ON $wpdb->posts.ID = $table_wpp.postid WHERE post_status = 'publish' AND post_password = '' AND $range AND pageviews > 0 $nopages $excludeCats GROUP BY postid ORDER BY $sortby DESC LIMIT " . $this->options_holder[$summoner]['limit'] . "";
    
    			//echo $mpQuery;
    
    			$mostpopular = $wpdb->get_results($mpQuery);

    in the $excludeCats string, the category id’s should be separated by commas. in my example, I’m only excluding category ID 17.

    i did it this way in case i needed to display categories which were previously excluded from results. this still allows Popular Posts to count pageviews/stats on excluded categories.

    great plugin, btw

    Nice snippet, erik! Will take a deeper look at it later this week, thanks for sharing it!

    Galerio

    (@galerio)

    Thanks, the code to exclude just some particular posts works well!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: WordPress Popular Posts] Omitting certain posts and manual update’ is closed to new replies.