Hot answers tagged

3

You can use WP_Query's pagination paramters. However, using two queries to accomplish this objective is inefficient. A better solution it to use one query and alter your markup based on the value of WP_Query's $current_post property, which (when used in the loop) reflects the index of the post currently being processed within the current page of results.


2

Your argument structure is not correct. It should be like [meta_query] => Array ( [0] => Array ( [key] => state [value] => a [compare] => LIKE ) [1] => Array ( [key] => state [value] => b ...


2

This Plugin gives you a list of posts for each Site already, but it does not exactly do what you want to do. Basically, it gives you a list of all posts in your network. What you need to do afterwards is sort them by site_id and create an output for that. I do not know if this is the best version - but as WP_Query returns an one-dimensional array, you need ...


1

In case anyone else needs the code, this is how I solved it. @pieter-goosen was right, I did need to query the correct posts, but the real trick was matching the date format from the jquery datepicker when running the post query. Check the date formats below, jquery is 'yy-mm-dd', and the php equivalent is 'Y-m-d'. So the js for the datepicker was: ...


1

To expand on the answer by Global: Paste this into your theme's functions.php: function get_stations_query( $terms ) { //create new query object $query = new WP_Query( array( 'post_type' => 'stations', 'post_status' => 'publish', 'posts_per_page' => -1, ...


1

You should really read the documentation on meta_query's Here is what is allowed in a meta_query key (string) - Custom field key. value (string|array) - Custom field value. It can be an array only when compare is 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN'. You don't have to specify a value when using the 'EXISTS' or 'NOT EXISTS' comparisons in WordPress ...



Only top voted, non community-wiki answers of a minimum length are eligible