Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I tried asking the plugin author and while waiting for a response I figured I'd give this place a try too.

This is what wordpress-popular-posts.php looks like: pastebin

Is there something I can change in there to include custom post types?

Maybe somewhere around line 132 since I'm calling the wpp_get_mostpopular function? I suppose I'd need to add custom post types to the list of arguments but I'm not sure where that would be.

share|improve this question
    
I noticed that if I add pages=1 to the list of attributes for wpp_get_mostpopular, it shows everything i.e. the posts in my custom post types and pages. However, if I use pages=0, it only shows the posts in the default post type. Would there be a way to only get rid of the actual pages? –  jwp Mar 17 '11 at 0:46
add comment

1 Answer

up vote 1 down vote accepted

Not sure if this is the right place... but line 496

$nopages = "AND $wpdb->posts.post_type = 'post'";

seems to be the only place I see any post selection limited to just post

When I've messed around with other plugins, to add in CPTs, I'v elooked for similar selection criteria. And added in my own CPTs. So the first place I would mess around is here. I'm not a coder, so I'm not sure exactly how to add in the CPT here....

$nopages = "AND $wpdb->posts.post_type = 'post', 'cpt', 'another'";

or if it has to be in an array

$nopages = "AND $wpdb->posts.post_type = array( 'post', 'cpt', 'another' )";

, or what.....

I'm sure you know to have a backup available, and that if you get the syntax wrong, you could kill the plugin, or your site. But as long as you can ftp in, no harm no foul really. I know I've killed my sites a few times doing stuff like this. Its why I have a dev install of WP that is pretty much a copy of my live site.... so I can poke it with a stick to see what happens

share|improve this answer
    
Oh, and if you do indeed get it figured out, take notes, or copy your code or something. As if/when the plugin gets updated, obviously your changes to the plugin would be undone –  Rev. Voodoo Mar 17 '11 at 11:35
    
Thanks for your help @Rev. In that line, changing post to another custom post type did it for me. Now I need to figure out how to put in an array of post types. I'm still a beginner on this as well. Not much of a coder but I'm learning. Hopefully someone can chime in. –  jwp Mar 17 '11 at 18:51
    
it'll either look like what I put above, 'post', 'cpt', 'another' or an array array( 'post', 'cpt', 'another' ) –  Rev. Voodoo Mar 17 '11 at 19:06
    
I've updated my post with possible examples. Again... these are just (semi)educated guesses here –  Rev. Voodoo Mar 17 '11 at 19:09
    
I actually just got help from someone and found the solution: $nopages = "AND $wpdb->posts.post_type IN ('post','videos','projects')"; I haven't tried your solutions but this one works so I think I'll stick with it for now. Thanks again for your help @Rev. –  jwp Mar 17 '11 at 19:11
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.