Register Taxonomy – What is `query_var`?

It is explained pretty thoroughly in the Codex, in my opinion. It serves a purpose e.g. when you want to grab posts for your taxonomy, it is a URL slug for your taxonomy, e.g. example.com/tag/cats -> example.com/query_var/cats. Note: The query_var is used for direct queries through WP_Query like new WP_Query( array( ‘people’ => $person_name ) … Read more

WP Query / Meta Query [duplicate]

Short answer: You can’t do that. The query system is a simplified version, by design. It cannot do combinations of ANDs and ORs across keys like that. If you want to do that, you’ll need to write your own SQL in some manner. The meta_query is not capable of that complex of a query.

Search for pages with permalink

If I understand well (and I’m not sure) probably you need only the get_page_by_path function: $pagefoo = get_page_by_path(‘foo/page2’); $pagefoo variable contain post object for the page with slug ‘page2’ that is child of page with slug ‘foo’.

WordPress WP_Query compare not working?

What you’re trying to achieve is a LIKE query. But you’re using the compare arguments that are only present for meta_query arguments. You need to utilize a filter like the following: add_filter( ‘posts_where’, ‘wpse120358TitleLike’, 10, 2 ); function wpse120358TitleLike( $where, &$wp_query ) { global $wpdb; if ( ‘post’ === $wp_query->get( ‘post_type’ ) AND $wp_query->get( ‘name’ … Read more

Trying to use WP_Query to display a custom post type

Typically, you would be echoing content from an action hook, rather than returning it, and from I can find about this Woo Theme hook that looks to be the case here too. Try echo $output; instead of return $output; See: Clarification on filters and hooks Difference Between Filter and Action Hooks?

Query custom taxonomy for category including children

tax_query is used to get the posts associated with certain taxonomy. {tax} (string) – use taxonomy slug. Deprecated as of Version 3.1 in favor of ‘tax_query’. tax_query (array) – use taxonomy parameters (available with Version 3.1). taxonomy (string) – Taxonomy. field (string) – Select taxonomy term by (‘id’ or ‘slug’) terms (int/string/array) – Taxonomy term(s). … Read more

Include one page/post into query which is already returning posts

And here is the correct implementation: Register the category taxonomy for the page post-type: function wpse121285_add_category_to_pages() { register_taxonomy_for_object_type(‘category’, ‘page’); } add_action( ‘admin_init’, ‘wpse121285_add_category_to_pages’ ); Add the appropriate category term to the desired page. Then modify the default $wp_query object at pre_get_posts: function wpse121285_pre_get_posts( $query ) { // Main query for the blog posts index // … Read more