WordPress pre_get_posts with combined results of two queries (OR)

See WP_Query as reference for the post query filters. You can filter posts by their authors with the ‘author’ query var as you filter posts by their taxonomy with ‘tax_query’ query var. Then, conditionally set the ‘tax_query’ query var depending on the user’s company meta field. If it’s empty, set the ‘author’ query var instead. … Read more

Insert content of a post into another

When you use return in your function, the rest of the function will not run. It work somehow like exit(); or die();, but it won’t terminate the entire script, only ends that particular piece of code in your function, and return a value if necessary. You should save your content into a string, and then … Read more

How to return another post than requested

If you can access the ID of your post, it means that the query has already been run. So, in this case, you can’t use pre_get_posts anymore. A solution would be to wrap your code in a conditional, and then use functions such as get_the_permalink() or get_the_title() which accept a post ID, to get the … Read more

WP_query return more results than SQL query. post_count > found_posts

post_status=”publish” is default yo WP_Query so you not need specified. As you can see real SQL query is ok. And all returned results are with status publish. looks like that only post_modified_gmt > ‘xxx’ is not respect. Currenly use construction with ‘fields’ => ‘ids’, so get only 14 post id’s and next foreach($query3->posts as $id) … Read more