Custom query return

Okay i’m going to try to add this as an answer because I can’t do codes in comments: <?php if($_GET[‘colour’] && !empty ($_GET[‘colour’])) { $colours= $_GET[‘colour’]; //notice i pluralized. } ?> //your code ended php, so i assume there is something here as it is not started again. $meta_query = array(‘relation’ => ‘OR’); foreach ($colours … Read more

WP Query issue for multiple values

You use $args but it isn’t define. IN your form, you need to add double bracket to make $colours an array. <INPUT TYPE=”checkbox” NAME=”colour[]” VALUE=”red”> Red<BR> <INPUT TYPE=”checkbox” NAME=”colour[]” VALUE=”blue”> Blue<BR> $value){ $colours[]=$value; } $meta_query = array(‘relation’ => ‘OR’); foreach ($colours as $colour) { $meta_query[] = array( ‘key’ => ‘colour’, ‘value’ => $colour, ‘compare’ => … Read more

Track write actions to the database

Seems like there’s a plugin out there that does quite this! It’s VersionPress! In this blog post is explained what they used to track all the complicated changes. Instead of using the ‘query’ filter they use the option to create a db.php file in the wp-contents directory to extend $wpdb like explained in this post: … Read more

Problem with custom WP_Query and underlying pagination/posts_per_page

Stop overriding the default loop and use pre_get_posts instead. Like this: function wpse_247208_custom_category_query( $query ) { // Return early for any situation you aren’t interested in. if ( is_admin() || ! $query->is_main_query() || !is_category() ) { return; } $query->set( ‘posts_per_page’, 6 ); // Don’t use a global; create a function to populate this value // … Read more