meta_query with array as value with multiple arrays

The default relation is AND so you really don’t need to specify that, but I’ll show you how to do it anyway. Really, you just have an array manipulation problem. $amenities = array(‘a’,’b’,’c’); $amenities2 = array(‘d’,’e’,’f’); foreach ($amenities as $a) { $arrays[] = array( ‘key’ => ‘amenities’, ‘value’ => $a, ‘compare’ => ‘LIKE’ ); } … Read more

Query Not working as expected

You aren’t preserving the paged query var in your query. You can accomplish this by making line 4: $wp_query = new WP_Query($query . “&paged=” . $original->query_vars[‘paged’]); UPDATE: After the edit on the OP, the issue was that the paging variable, paged was in the query being sent to the function. But, there was a typo … Read more

Get Post ID as a separate RSS feed item

How did I workaround this? Step1: From my WordPress Permalink Settings, I selected Custom Structure and added /%post_id%/ This means my results will be in this format: <myurl>/<postID> Step2: To make it easier for me instead of writing a regex query I used a a Split command like this: var postlink = entry.link; var id … Read more

Insert images into wordpress post with a query

Yes, it is possible, WordPress does not have an API, but some useful functions. I would load all your rows into array like $your_table = [‘post_id’ => ‘image’, ‘post_id’ => ‘image’, …] Then execute a foreach loop foreach($your_table as $post_id => $image) { //full path to the image $image_path = _YOUR_FULL_ABSOLUTE_PATH.$image; /** * Get an … Read more

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