WP_Query for posts that have postmeta assigned to a taxonomy

So I found the solution after tons of searching from the events calendar’s website and modified it to suit my needs. The code is as shown below: (Note I also removed the array to string conversion since it’s pretty pointless.) <?php // Support for multiple locations to be filtered. $request_cities = array_map(function($item){return utf8_decode(urldecode($item));}, explode(‘+’, $_REQUEST[‘city’])); … Read more

WP_Query & shortcode : Return 3 articles from a category WordPress

The problem is your $contenu variable. Try: $contenu .= ‘<div class=”effect-jazz”>’.get_the_post_thumbnail().'<div class=”jazz-try”> <div class=”h3″><a href=”‘.get_permalink().'”>’.get_the_title().'</a></div> <p>’.get_the_resume(60).'</p><!– THIS FUNCTION NEEDS TO BE CREATED –> </div> </div>’; Do not use ; trailers when using inline php, ex <a href=”‘.get_permalink().'”>. Use the appropriate return functions: get_the_post_thumbnail() get_permalink() get_the_title() Create a return version of the_resume() function Do use the … Read more

meta_query is not allowing to show posts when querying multiple arguments in a WP_Query

Try this one <?php $date_today = time(); $args = array( ‘post_type’ => ‘birthday’, ‘posts_per_page’ => 1, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘field_position’, ‘value’ => ‘Teacher’ ), array( ‘key’ => ‘field_dob’, ‘value’ => $date_today, ‘compare’ => ‘=’, ) ) ); $the_query = new WP_Query($args); if($the_query->have_posts()) : while($the_query->have_posts()): $the_query->the_post(); the_title(); endwhile; endif; ?>

custom search form, posts_per_page value being ignored

You can set the posts_per_page with pre_get_posts action like this: add_action( ‘pre_get_posts’, ‘my_set_posts_per_page’ ); function my_set_posts_per_page( $query ){ if ( is_admin() ){ return; } //Check if this is a search if ( isset( $query->query[‘s’] ) ) { $query->set( ‘posts_per_page’, -1 ); } }