Select random post every day

Note that the posts_orderby filter is not available for get_posts() where suppress_filters is true by default. You can use WP_Query instead: $args = [ ‘posts_per_page’ => 1, ‘orderby’ => ‘rand’, ‘post_type’ => ‘listing’, ‘ignore_sticky_posts’ => true, ]; add_filter( ‘posts_orderby’, ‘force_random_day_seed’ ); $q = new WP_Query( $args ); remove_filter( ‘posts_orderby’, ‘force_random_day_seed’ ); if( $q->have_posts() ) { … Read more

Ignore/Skip default value on orderby menu_order?

You can try the following (untested) mini plugin: <?php /** * Plugin Name: Support for ignoring the default menu order in WP_Query * Description: Uses the _ignore_default_menu_order argument * Plugin URI: http://wordpress.stackexchange.com/a/193291/26350 */ add_filter( ‘posts_where’, function( $where, $q ) { global $wpdb; if( (bool) $q->get( ‘_ignore_default_menu_order’ ) ) { $where .= “AND {$wpdb->posts}.menu_order <> 0”; … Read more

Filter user list that meta_value is empty

I think the use of meta_query is in order: $user_query = new WP_User_Query( array( ‘meta_query’=> array( array( ‘key’=> ‘birthday’, ‘compare’ => ‘NOT EXISTS’ ) ) ) ); Basically, this looks for all users where the meta key of birthday doesn’t have a value ie doesn’t exist. More info about meta queries in WP_User_Query can be … Read more

Array Chunks and Inserting Varying HTML in WP_Query

That’s a pretty complicated approach you’re taking. Why not simply add a counter? Like this: $i=1; echo ‘<div class=”row full”>’; if( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); if ($i < 3) $class = “large-6 medium-6 small-12 columns” else “large-4 medium-4 small-12 columns”; echo ‘<div class=”‘ . $class . ‘”>’ … output your … Read more

Is temporarily overwriting $wp_query a bad idea?

In general, I agree with Howdy_McGee that one should avoid overwriting the main query unless absolutely necessary – more often than not, modifying the main query with something like a ‘pre_get_posts’ hook is a better solution to such scenarios. Manually overwriting the global $wp_query can cause all sorts of unintended behaviors if you are not … Read more

meta_key and meta_value not working together

You could try this: $args = array( ‘post_type’ => ‘cqpp_interventions’, ‘posts_per_page’ => ‘-1’, ‘meta_query’ => array( array( ‘key’ => ‘priority’, ‘value’ => ’80’ ) ) ); The real issue with your query is because you are passing meta_key and meta_value. However, the arrays in your meta_query argument should have the keys key and value instead. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)