I’m currently working on a search function in a wp site. The plan is to have a search function on the news page which just searches posts. I’m achieving...
I want to replace the main query with my own custom query. The thing is I don’t want to go through the hassle of manual paging. I know there’s...
I have the current function on my theme using pre_get_posts, currently right at the bottom of my theme’s functions.php file: function mytheme_portfolio_archive_pages( $query ) { if ( is_admin() ||...
I’m trying to exclude the first 5 posts from the first page on the homepage, but I’m unable to get it right. This is the patern that I’d like...
I’m trying to sort my posts by the custom field artwork_title. When I use the following code, I just end up with one particular category of posts no matter...
I’m creating a plugin that adds a custom feed. I am using a pre_get_posts filter to change the posts_per_page query var to -1 (to get all items of a...
I am modifying the query for custom archive pages. I am using the pre_get_posts action. I need to catch some GET variables to modify my query. It is working...
I want multiple orderby meta_query eg: orderby(‘_property_price’ => ‘DESC’,’_property_featured’ => ‘DESC’) This is what I am doing $query->set('meta_key',array('_property_price','_property_featured')); $query->set('orderby',array('meta_value'=>'DESC')); In SQL, it should be like ORDER BY _property_price, _property_featured...
i need to change the posts in taxonomy.php page. I have a meta_key which i want to compare to meta value. But currently my code is not returning anything....
I have an ajax request that returns the result of a WP_Query loop. I would like to detect in pre_get_posts filter the specific wp_query instance that is used in...