Optimize WP_Query
Optimize WP_Query
Optimize WP_Query
Eliminate typical pages on search page, turn it into ajax search with “infinite” sized single page
previous_posts_link not working in WordPress pagination
You should be able to get that number from the same $wp_query object: global $wp_query; $num_pages = $wp_query->found_posts; $num_pages will contain the total count that matches your category (or whatever other criteria you’re using). If you’re just looking to get a string you can display, this modified version of the function will work. function get_post_number() … Read more
It sounds to me like you want to get the most recent term from your issue_filter taxonomy. To do that you’d want to use get_terms() with a few arguments. $t = get_terms( ‘issue_filter’, array( ‘orderby’ => ‘id’, ‘order’ => ‘DESC’, ‘number’ => 1, ‘fields’ => ‘ids’ ) ); That should get you the most recently … Read more
please modified yoy loop to display single post which you have coded in single.php file <?php // Start the loop. while ( have_posts() ) : the_post(); /* * Include the post format-specific template for the content. If you want to * use this in a child theme, then include a file called called content-___.php * … Read more
To get only child pages (pages that have parent selected), you can use this query: http://example.com/api/get_posts/?post_type=page&posts_per_page=1&orderby=rand&post_parent__not_in[]= And that should also give you the answer for your second question, I guess 😉 If you want to pass array(1=>’foo’, 2=>’bar’) as param called my_array, you should use this query: …&my_array[1]=foo&my_array[2]=bar
You may be able to use the LIKE operator: $meta_args[] = array( ‘key’ => ‘availability’, ‘value’ => $availability, ‘compare’ => ‘LIKE’ ); In the codex you can see a list of comparison operators.
I’m not sure what convention is with pre_get_posts, but it seems to be for setting additional arguments and not replacing then running the query. Comparing wp_query and my own geo query, I noticed my own had post data in the query object. This may have been what caused the memory leak, but it must have … Read more
How to make the default WordPress search return borader results