Is the 404 page automatically displayed if a loop returns nothing?

If you want to force the 404.php template to load if there are no found posts, use the template_include filter: function wpa84794_template_check( $template ) { global $wp_query; if ( 0 == $wp_query->found_posts ){ $template = locate_template( array( ‘404.php’, $template ), false ); } return $template; } add_filter( ‘template_include’, ‘wpa84794_template_check’ );

Pagination on category.php and tag.php not working

If you merely want to modify posts_per_page for tag and category archive index pages, don’t use query_posts(); instead, filter the $query via pre_get_posts: function wpse87489_filter_pre_get_posts( $query ) { if ( ( is_category() || is_tag() ) && $query->is_main_query ) { $query->set( ‘posts_per_page’, ‘2’ ); } } add_action( ‘pre_get_posts’, ‘wpse87489_filter_pre_get_posts’ );

New loop vs widget

You should always use widgets when you need to add any kind of content to the sidebar. The reason is very practical – once the project is over the owner of the site will not need to contact you just because he wants to put a banner before your “loop”, and even during development it … Read more

older blog posts not showing in new theme

What posts exactly are not shown? In your code there are no page links (pagination). Could it be that you just see the the number of posts according to the respective admin setting? In addition, I just have been learned NOT to use query_posts. Why would you use it there anyway? Assuming, this is a … Read more

Contact information footer

Another option is to create a new post type called “modules” or something to that effect. Then you can create as many of those as you like, for example, “Footer: Contact Information,” “Footer: Social Media,” “Header: Callout,” etc, and you can use that post’s ID to bring it into the designated spots in your template. … Read more

How to create a multidimensional array with multiple loops

I don’t think this is a restrict WordPress question, but you might try $args = array( ‘posts_per_page’ => ‘-1’, ‘post_type’ => ‘work’, ‘orderby’ => ‘ID’, ‘order’ => ‘DESC’, ); $data = array(‘work’ => array()); $loop = new WP_Query($args); if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post(); $id = $loop->post->ID; $attachments=array(); if(get_field(‘work’)): while(has_sub_field(‘work’)): $attachment_id = get_sub_field(‘image’); $caption … Read more

Put multiple custom loops on same page

Because you used query_posts your loop-land template is clobbering the main query. Don’t use query_posts. In loop-land do this instead: $land = new WP_Query($query_string . ‘&caller_get_posts=1&posts_per_page=9’); if($land->have_posts()) : while($land->have_posts()) : $land->the_post(); What happens is that query_posts overwrites the main Loop and you loop over that. When you get to the have_posts part of the second … Read more