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

Add custom taxonomy to custom search for posts

you should go through all wpQuery docs for easily understand this. To do this task use this for for making query: $args = array( ‘post_type’ => ‘your_custom_postType’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘your texonomy ‘, //like category, actor, people etc. ‘field’ => ‘slug’, ‘terms’ => ‘your_term’, //like rock,bread, tom ), ), ); $query = … 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 ); } }

wp_query returns match with no criteria

After digging into this for a big, what I discovered by reviewing the actual SQL via $the_query->request was that if no meta value identified it will return true simply because the query eliminates it. The solution was to simply include the the meta as an array and use the “compare” operator.