Multiple loops are not reset
At the end of your news.php, use wp_reset_query(). This will revert to the default query for that page. Hope this helps! Codex Function Reference for wp_reset_query()
At the end of your news.php, use wp_reset_query(). This will revert to the default query for that page. Hope this helps! Codex Function Reference for wp_reset_query()
I recommend you use the pre_get_posts filter or ditch query_posts and use WP Query. That way you can easily use category__not_in (array) parameter and not mess any other loops up. function exclude_category($query) { // this requires term id instead of term name so change “20” to the “sport” id // this assumes “sports” is in … Read more
$movies = new Wp_Query(‘tag=movie-reviews&posts_per_page=5’);
Here’s a function to do a query with multiple taxonomies: function posts_search ($post_type,$taxonomies) { // $taxonomies should be an array (‘taxonomy’=>’term’, ‘taxonomy2’=>’term2’) foreach ($taxonomies as $key=>$value) { $args=array(‘post_type’=>$post_type,’post__in’=>$ids,$key=>$value); unset($ids); $ids=array(); foreach($posts=get_posts($args) as $post) { $ids[]=$post->ID; } if (empty($ids)) return false; } return $posts; } And here’s an example on how i used it in a … Read more
the_content_limit does not exist in WordPress. You probably want something like the_excerpt. What’s likely happening is your loop is working fine, but the call to an undefined function causes the program to error out, making it appear the the loop is not working. Look at the rendered HTML: you’ll probably see a single, opening <li> … Read more
First, Welcome! I guess you use the file front-page.php for displaying your homepage. What you have to do, is add the following code into your front-page.php: <h2>Recent Posts</h2> <ul> <?php $args = array( ‘numberposts’ => ‘5’ ); $recent_posts = wp_get_recent_posts( $args ); foreach( $recent_posts as $recent ){ echo ‘<li><a href=”‘ . get_permalink($recent[“ID”]) . ‘” title=”Look … Read more
pre_get_posts runs on every query, so you want to check if is_main_query() so it only applies to the default query and not additional queries you run on the page. You should also get in the habit of referencing the query object passed to the function like $query->is_category(), as calling is_category() is a wrapper for $wp_query->is_category(), … Read more
Your foreach is way wrong. Try combining the category ids in an array, then running one query only to get the posts you want. Edit: read your comments. Try use using an array function like array_merge instead of the + to combine the resulting post arrays. See if that helps.
Now, is it possible to check if page is the search page is_search() AND what’s the search string is_search() AND print get_query_var( ‘s’ ) AND how many posts were found? is_search() AND print $GLOBALS[‘wp_query’]->number_posts() … or if you got a custom query… $my_query = new WP_Query( array( /* whatever args */ ) ); is_search() AND … Read more
You could use query_posts() to set up a new loop in your page. Assuming that the posts you want are in the category ‘Noticias’, with a slug of ‘noticias’: query_posts( ‘category=noticias’ ); if( have_posts() ) { get_template_part( ‘loop’, ‘index’ ); } wp_reset_query(); // probably not necessary, if you don’t have a pre-existing Loop