Set right order for query that returns posts based on two custom fields
Set right order for query that returns posts based on two custom fields
Set right order for query that returns posts based on two custom fields
The problem with this, as it often is, is not just homepage, but the continuous nature of pagination. Let’s say we start with 10 posts on home page and 5 of them social. Client says that they would like 2 less of social. We can get rid of them easily enough, but now we need … Read more
I know you asked for no plugin suggestion but I thought I’d share the solution I commonly use for creating advanced search forms in WordPress. http://wpadvancedsearch.com/ This is not a plugin but a PHP framework for building advanced search forms in WordPress. It has served me especially well with custom post types and creating search … Read more
Custom query from all posts & all child page from one parent page?
Using WP_Query to get attachment returns empty set
When you inspect your SQL query right after you executed it $GLOBALS[‘wp_query’]->last_query you will see that the SQL statement is asking for AND. Jump into the posts_where or the the posts_clauses filter (where you need to look up the where keys value) and alter it to OR.
add_query_vars does not work
I found this and it works. The big difference is that it checks if $post count == 0 and the creates the virtual page which will then allow all the other queries to function as normal. <?php /* Plugin Name: Virtual Page Plugin URI: http://davejesch.com Description: Create a virtual page with content Author: Dave Jesch … Read more
Ok then, I actually was getting the subcats with the wrong method. in $parent_cat = get_cat_ID( $cat_name ); $cat_name wasn’t a name but un slug. First mistake. So I corrected with $parent_cat = get_category_by_slug( $cat_slug ); The final code is : // Get the parent cat thanks to the page’s cat slug $parent_cat = get_category_by_slug( … Read more
using next-page and previous page inside a wp_query