“Inside the Loop” essentially means that function relies on data from global variables (such as $post
) that are set up when Loop runs. Note that this is not necessarily done by main Loop of query_posts()
.
In your specific code those variables are filled by $custom_posts->the_post()
calls and after that wp_reset_query()
gets those values back to initial state.
Related Posts:
- How to get next and previous post links, alphabetically by title, across post types, in a shortcode
- Thumbnail (featured image) of next and previous post is not being properly displayed!
- Next/Previous Posts Links: Alphabetically and from Same Category
- Disable “previous link” in first post and “next link” in last post
- Next and prev. post link ONLY within category
- Previous/Next Post Within the Category?
- previous_post_link() next_post_link() arrow position
- Add #anchor to next/previous_post_link
- Using ‘previous_post_link()’ & ‘next_post_link()’ on single attachment pages
- get_next_post_link() and get_previous_post_link() return wrong posts
- WordPress next/prev links Issue
- Single: Prev and next Post in same order as main query, in all categories
- Get previous/next post from (specific) category
- altering %title
- Include scheduled ( future ) posts in WordPress post navigation ( previous_post_link, next_post_link )
- next/previous post links for specific category when post belongs to multiple categories
- Show category in Previous/Next links
- How to Navigate within Category? Lot of codes here on stackexchange didn’t work
- Multiple next / previous
- Single post navigation Previous post link shows up but Next post link doesn’t
- Next/previous post link to posts only within one or more specific categories
- How to add thumbnail support to WordPress next / previous post loop?
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- is it possible to get next_post_link
- Get Previous & Next posts by Post ID
- Filter next_post_link() and previous_post_link() by meta_key?
- How can I add title attributes to next and previous post link functions?
- Filter get_adjacent_post() for private posts, how to modify JOIN/WHERE?
- How can I get next/ previous post links to order by a filter (by the last word of the title)?
- next and previous post link ordered alphabetically
- How to use next_post_link and previous_post_link on single posts in search results
- How can I get next post id after current post id for custom post type
- Next and previous link in custom post type in the same taxonomy term
- adding custom fields to next and previous post link
- next_posts_link not working in custom loop
- Making next_posts_link(); return posts by month
- WordPress previous_post_link exclude posts with multiple categories
- Showing Thumbnail from Previous and Next Posts
- Working with Next and Prev links in Single Taxonomy Templates
- How to show link to next posts in single.php
- Next and Previous links on a single taxonomy page only link to same term
- connect last post with first post
- WordPress “Next Post” URL and Thumbnail
- “next_posts_link” and “previous_posts_link” display me NOTHING
- Can I use get_adjacent_post for specific categories?
- Next and/or previous post content
- next_post_link for CPT only working for a few posts? weird!
- Is it possible to nest get_previous_post()?
- Exclude Posts From Specific Category from Next and Previous post links
- Check if next post is available and output a link
- get rid of the arrow in previous_post_link?
- Is it possible to skip certain specified pages when using < prev and next > links?
- Change OR logic of get_adjacent_post into AND
- previous/next_post_link in the same sub-category?
- Next Posts Prev Posts for Standard post format only
- get_adjacent_post – in same term or category not working
- previous_posts_link and next_posts_link, how to return the next/previous post’s title as the url
- next_post_link / previous_post_link not working with WP_Query
- Displaying the author of next and previous posts in pagination?
- Single.php Category Post Count
- Why are previous_post_link/next_post_link skipping some posts?
- Add Previous/Next Buttons to CPT Single Pages Only
- WordPress post pagination continuous [duplicate]
- WordPress post next/prev not working
- Tweak next_post_link for it to include thumbnail
- Fetching All Posts (200+) in a Category – Performance Issues?
- get_adjacent_post – in same term not working
- Can’t get the previous and next posts permalink
- navigation among single posts
- Next/Previous links doesn’t work in the same category
- Next Prev Post link rendering current post thumbnail
- How do I display a greyed out next_post_link when there is no next post
- WP_Query and pagination AGAIN?
- pagination links not displaying
- Next/Previous Product with custom order by price & products inside the product category [closed]
- How to get next post link of child custom post type from parent post and get next post link of parent post from the last child post?
- Order by post_date does not work in Previous and Next post pagination
- Infinite next / prev post in single.php page
- How to exclude posts by meta key value in the_post_navigation next prev links?
- Prev/Next Navigation on Single Post Disappeared for Custom Post Type
- Using previous_post_link next_post_link but with a filter on a custom field
- make random internal linking in the middle of posting
- Back, Next, and Previous links for the REFERRING term archive
- get_previous_post_link and get_next_post_link of custom post type that share custom field value
- Previous/Next custom post links within custom taxonomy
- How to know if the most recent article
- How do I modify the Previous and Next Page posts on blog pages to include “previous” and “next” before the links?
- I need to customize wordpress “previous” “next” links
- Conditionally (cpt) filter previous and next_post_link
- Next/Previous Post Links in single-[custom-post-type].php file
- WordPress not showing pagination links
- Next and Prev post link breaks code on last post
- using next-page and previous page inside a wp_query
- previous_posts_link returns null when querying custom post type
- single post navigation order (NOT chronological)
- How to add a class and title attribute to the link generated by next/previous post
- Change next_post and previous_link to navigate throught parent categories only
- Retrieving next_post_link() and previous_post_link() in functions.php
- how to implement next/prev within category archive?
- on attachment.php, how to display previous and next attachment links that follow the same order as a custom WP Query