$wp_query->queried_object->ID throws warning: Undefined property
I faced the exact same problem for days and then found this! Use the function $wp_query->get_queried_object_id(). Check this for more details.
I faced the exact same problem for days and then found this! Use the function $wp_query->get_queried_object_id(). Check this for more details.
First, your date format has to be in descending order from largest to smallest units, i.e.: year, month, day, hour, minute, second, etc., otherwise MySQL can’t query or order on the field. In this example I use year – month – day: $today = date( ‘Y-m-d’ ); $args = array( ‘post_type’ => ‘vehicle’, ‘meta_query’ => … Read more
So this is what I needed: <?php $terms = get_the_terms( $post->ID , ‘board’ ); foreach ( $terms as $term ) { echo $term->name; } ?>
This is actually a tricky question, as by stating exact there are two ways in which one can interprit your question – Only find posts where the whole title or the whole content match exactly. For example, if you search My post is super you would not have returned a post with the title My … Read more
What you are experiencing is quite normal and expected. This is one of the big reasons I always hammer on this point, never use custom queries to replace the main query on the home page or any type of archive page. They solve one issue but creates plenty other new ones Lets look at what … Read more
The offset index for WP_Query generally works with pagination. When you set pagination to a -1 the function assumes you’re getting all posts and there will be no pagination or offset. So to counteract this you would set the posts_per_page to a high number like 999. Reading the Function Reference on WP_Query the pagination section … Read more
There’s a way to set custom post-type search. I can only head you in the right direction and answer the first part of your question. The other part about COOKIES you’ll have to review php documentation. Also, I don’t know exactly what the other $_REQUEST variables you may have set for your custom post type. … Read more
You have a syntax-ish error, or a spelling one. There is a space after “taxonomy” in your tax_query array. If that were the sum of it I’d have just posted a comment, but additionally that $query->tax_query->queries[] = $workspace_taxonomy_query; line is pointless. Nothing changes with or without it. Don’t try to hack the array like that. … Read more
Whenever you use the function get_post_meta(), the above query will be performed to get all post meta and store in the cache. The more posts you query, the more queries are made. To reduce the number of queries, we should pre-cache all meta values of all posts in the query before calling get_post_meta. This is … Read more
I think we can simplify it with: $request = new WP_REST_Request( ‘GET’, ‘/wp/v2/posts’ ); $response = rest_do_request( $request ); $data = rest_get_server()->response_to_data( $response, true ); by using rest_do_request().