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 information visit this page.
Related Posts:
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- Pass the same object to multiple widgets in a template with one query
- How can i make WP_Query return post image and categories?
- How to detect if query is runned from widget?
- Most commented last 24h, week, month, year and all time – posts_where
- Show post number in widget loop
- Error with function in functions.php?
- How to create a widget like this?
- All Posts Have The Same Comments
- Widget only in first post
- How to add a recent post function to a text widget I created for practice?
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- How can I show only last year posts in wordpress archive?
- wp_query in form method of widget breaks customizer
- Wp_query to get woocomerce product categorys [closed]
- Order by DESC, ASC in custom WP_Query
- Exclude or Include category ids in WP_Query
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Query Posts in a Predefined Order
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- How to query for a week using key => value WP_Query argument notation?
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- How can I style future post?
- List taxonomy terms plus their latest post ordered by post date
- WordPress altering my custom query, How to fix it?
- Looping through tabular data
- Using next/previous_posts_link with customised search
- How to create/modfiy WP_Query to search in post title OR custom field?
- How to detect custom query inside `posts_where` hook?
- Is temporarily overwriting $wp_query a bad idea?
- Array Chunks and Inserting Varying HTML in WP_Query
- Using apply_filters(‘the_content’, $custom_query->post_content) alters output
- WP_Query Date Query After Minus Hour AND minus minutes
- Get posts for last working week in WP_Query
- How to select events within current week using wp_query
- how to link to detail page(single.php?) in a wp_loop
- WP_User_Query unable to retreive all user at once
- Meta Query Array Error 500
- Display posts from only one post form in custom query and exclude in main query
- Get pagination working for custom loops within page templates
- Complex WP SQL Query
- Hide Administrators From User List except current user (administrator)
- How to get all product attributes for filters in WooCommerce?
- Fetch Record based on meta key dates
- How can I display list of all posts from a specific author, with publish dates in the future, on an author archive page (author.php)?
- Custom posts visible in admin, but truncate in public
- How to figure out redirection and contents in hybrid solution containing word press content and legacy code (ASP.net)
- Query to get siblings and parent page
- Why does get_posts only show results for Admins or logged-out users?
- How to store and receive variables in WP sessions?
- How to query for all posts that have a particular meta key?
- Custom taxonomy.php not working
- Ajax future single post query doesn’t work when NOT logged in
- Conditional sorting with variable using WP Query
- Get multiple users with meta value in one query and populate WP_User class
- WP_Query calls all posts?
- WP_Query Taxonomy categories filtering
- WP_Query: apply an SQL function to meta fileld value
- The best way to store variable across different widgets
- Assign a minimum result count for WooCommerce query shortcodes?
- WPQuery calling specific posts problem
- Retrieve data from wordpress db via input and put those result in dropdown
- Filtering by multiple conditions in the loop
- Limit loop to future events
- How to access $wp_query object from array of posts given by get_posts?
- Echo User Name from User with most comments of today?
- Custom wp_query differs on index page and category page
- WordPress Queries Not Working?
- Links in the_content not linked
- how do I write this wp_query select statement?
- How to make a post with certain taxonomy term display first before other post with only one query?
- Exception for excluding previously displayed posts in queries
- Post incorrectly excluded when using “category__in”?
- How do I compare the value of two taxonomies in a wp_query
- query hook parse_tax_query function takes no effect
- Query by meta key and order by another meta key value
- Categories In English version showing not canonical URL, instead shows query search result
- Related posts queries
- Check for not NULL not working in meta query
- Display hierarchical structure of Custom post type in UL LI
- Pagination for Category does not work
- Query against multiple locations within single custom post type post
- ACF query-pass field value
- How to make a search query if not found in post table then search in postmeta table?
- In which file to use $wpdb and its functions for database operations and queries in wordpress?
- how to show more than 1 post into three columns query
- tax_query not working for taxonomy slug
- Problem with infinite scroll on multisite with custom query
- active link for most recent post on vertical tabs
- How to Insert data with wp cron
- Get X posts for all post types on Taxonomy term archive
- How to list posts of a given format
- Page displaying 1st post from a range of custom tax?
- WP Query Bug? Cannot find out why posts are not found!
- get contents and permalink from a specified page
- What query to append the 10 next posts?
- How ‘secure’ are loops?
- What triggers these wordpress queries on my homepage?
- How to do a loop inside a loop?
- Pagination not working in secondary query