Split WP_POST table based on post types

You could filter ‘query’ (you get the complete SQL here) and search for the post type in that. Then switch the database depending on what you found. But I don’t think this would work well: You might end up with the same post ID used multiple times (in each DB) and some strange side effects … Read more

Restrict post navigation to current sub menu

As @Ravs mentions the third parameter in next_post_link()/previous_post_link() should be a boolean value indicating whether to restrict the link to a post in the same category. By default this is false. If set to true, it will choose the next (or previous) post which is in the same category as the current post. This includes … Read more

Notice: Undefined index: suppress_filters

If $query->query_vars[‘suppress_filters’] is not set you will get that message. Use empty($query->query_vars[‘suppress_filters’]) instead of false == $query->query_vars[‘suppress_filters’] ) or use $query->get(‘suppress_filters’) like this false == $query->get(‘suppress_filters’). Untested (minimally tested) but I believe either of those should give you the same results minus the notice.

WP_Query get posts from custom posts by category

You’re using category query for your custom taxonomy. So it won’t work, because there are no categories with such IDs. You should use tax_query instead. // post types query while ( have_posts() ) { the_post(); // getting the categories $categoryIDs = array(); // it’s much nicer than concatenated string $getcategory = get_the_terms($post->ID, ‘custompostnamehere-categories’); foreach($getcategory as … Read more

Private Posts/Pages & Search

This is the default WordPress behavior. http://codex.wordpress.org/Content_Visibility#Private_Content Private posts are automatically published but not visible to anyone but those with the appropriate permission levels (Editor or Administrator). WARNING: If your site has multiple editors or administrators, they will be able to see your protected and private posts in the Edit panel. If you want to … Read more

Get random posts between specific dates / of specific age

Two notes beforehand: There is no (unless you created a CPT) post type random_posts. Don’t use query_posts. That being said, the following will do what you want: Just the randomness $args = array( ‘posts_per_page’ => ’10’, ‘orderby’ => ‘rand’ ); $random_posts = get_posts( $args ); foreach( $random_posts as $random_post ) { // do something echo … Read more