This code works perfectly function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-1' ); } } add_action( 'pre_get_posts', 'exclude_category' ); But this code...
I am trying to sort posts by custom taxonomy. I have a custom post type which is course-cpt and I have created custom taxonomies within it, I need to...
This question is a follow up to a question I recently asked. I’ve implemented what seemed to be the only solution, and it seems to work (YAY!). I just...
I am a new WP plugin developer. I want the search page to include only the current user’s posts. I first added a new capability read_others_posts to only administrators...
I have a meta_key on all posts that is designed to check the current user role and only return the post if the user has an acceptable user role....
I have two loops in archive.php, both are affected by pre_get_post. My code on pre_get_post is this: // My pre_get_post function my_pre_get_posts( $query ) { if ( is_admin() ||...
I have created a filter to skip first post of the archive on “podcast” category. Below is the code. add_filter( 'pre_get_posts', 'amd_limit_posts'); function amd_limit_posts($query){ if (is_category('podcast')){ $query->set('posts_per_page', 4); $query->set('offset',...
I want that my search page give results of posts (that i want that show) and taxonomy The code to get just two type of posts: function searchfilter($query) {...
I have a category archive page (press), which I need to loop through posts of a certain tag (magazines). I tried to modify the query with pre_get_posts, but it...
My understanding is, that custom post types can share tags with the posts also. I have created tags and applied them to a blog post and a custom post...