Why isn’t my `meta_query` array functioning properly?

I already got it. Was missing an extra array() in the meta_query. My updated code is this: I’d like to thank this website. Sometimes just posting the question helps me figure it out. What a cool community. Good luck and happy coding, all. <?php $artist_id = get_the_ID(); $want_to_sell = new WP_Query( array( ‘post_type’ => ‘want-to-sell-post’, … Read more

Filter by custom field (meta_key) using JSON API

As this is too much for a comment, I’ll post here and delete later: http://example.org // domain ?json=get_recent_posts // controller # Arguments for the query start here &post_type=mytype &custom_fields=myfield &include=title,custom_fields &meta_key=myfield &meta_value=myvalue Have you tried the following? Debug the response: http://www.example.org/api/get_page_index/?dev=1 Widget-style JSONP output: http://www.example.org/api/get_recent_posts/?callback=show_posts_widget&read_more=More&count=3 Redirect on error: http://www.example.org/api/posts/create_post/?callback_error=http%3A%2F%2Fwww.example.org%2Fhelp.html And could you post what you … Read more

Query multiple meta values

You code is generating a broken meta_query. You code will produce something like this: array(1) { [“meta_query”]=> array(2) { [0]=> array(2) { [“relation”]=> string(2) “OR” [0]=> array(3) { [“key”]=> string(4) “test” [“value”]=> string(10) “test_value” [“compare”]=> string(4) “LIKE” } } } It should look like this: array(1) { [“meta_query”]=> array(2) { [“relation”]=> string(2) “OR” [0]=> array(3) … Read more

How to create a Custom Meta Box with Name/Value Admin User Input Fields?

To help you understanding how forms work: They add to the $_POST array by a form fields name argument. <input type=”text” name=”foo” value=”Fooo!” /> would produce $_POST (array) => foo => Fooo! while <input type=”text” name=”foo[bar]” value=”Bar.” /> <input type=”text” name=”foo[baz]” value=”Baz.” /> would produce $_POST (array) => foo => (array) => bar => Bar. … Read more

Add meta value to custom post type on publish

You are usgin an undefined $post->ID variable because there is no reference to any $post object in your code; instead, use the $post_ID variable retrieved in the function: function on_jobs_publish( $post_ID ) { global $wpdb; $wpdb->insert( ‘iCrewzWp_postmeta’, array( ‘post_id’ => $post_ID, ‘meta_key’ => ‘_yoast_wpseo_sitemap-include’, ‘meta_value’ => ‘always’ ), array( ‘%d’, ‘%s’, ‘%s’ ) ); } … Read more