paginate_links() adds empty href to first page and previous link

Have you tried specifying the base and format arguments for paginate_links()? It assumes the default values of: ‘base’ => ‘%_%’, ‘format’ => ‘?page=%#%’, Your base should be something like /parent-page/child-page/%_%; then the first page link will be to /parent-page/child-page/, and subsequent links will follow the format /parent-page/child-page/?page=3 (example for page 3). In the base, the … Read more

Pagination returns 404 after page 20

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

WP_Query result in form of Rest API results

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().

How to do a wp_query using “BETWEEN” with two meta_values?

This should work for you: $tEA = array( ‘post_type’ => ‘event’, // you dont need meta_key as you use meta_query //’meta_key’ => $metaKey, ‘orderby’ => ‘meta_value’, ‘order’ => $order, ‘posts_per_page’ => $postPerPage, ‘meta_query’ => array( array( ‘key’ => $metaKey, // value should be array of (lower, higher) with BETWEEN ‘value’ => array(‘START_DATE’, ‘END_DATE’), ‘compare’ => … Read more

WP query taxonomy input differs to output?

A curious journey of a “cat“ Let’s assume we have the following category hierarchy: where the relevant rows from the wp_term_taxonomy table are: We want to query all posts in the animals category where the id is 65: $query = new WP_Query( array( ‘cat’ => 65 ) ); and try to understand why the resulting … Read more