Retrieving list of a custom post type in a widget without using WP_Query?
Use wp_reset_postdata() function after while loop to reset custom wp_query as shown in following code so that it will not break other wordpress loop. <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query(‘post_type=jobs&posts_per_page=8’); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/98851/<?php the_permalink(); ?>”><?php the_title(); ?></a></li> <?php endwhile; ?> <?php wp_reset_postdata(); ?> For more … Read more