almost!
when doing it outside of the loop, you have to reset the query as in:
wp_reset_query();
Related Posts:
- Highlighting wp_nav_menu() Ancestor Class w/o Children in Nav Structure?
- How to get the posts of a custom taxonomy term
- Why are the comments disabled by default on my custom_post_types?
- How can I rewrite URLs to pass taxonomy and post type values to the query?
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Custom Post Type menu name
- Get Custom post with ID
- Adding %author% in custom post type URL structure?
- Syntax to get the Nth item in a list of custom post types?
- Filter by custom Field for Custom post type Admin Listing
- Problem excluding category from get_next_post
- remove support for ‘Categories’ for a custom post type
- Display different gutenberg template from selected post attributes
- Recent comments on author page?
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- WordPress custom post type Single.php?
- Display custom taxonomy as dropdown list
- WordPress is executing URL in code when called via wp_mail()
- Automatically Add a Category to a Custom Post Type
- Detect if 1st, 2nd or 3rd level custom page?
- How to use custom fields to enable sticky posts on custom post types?
- Pagination problem
- Custom meta fields for specific custom type only
- Display different custom post type each week
- Custom Fields vs Separate Table
- Loop that displays the first post of every available custom post type?
- How do I prefix blog post urls as mysite.com/blog/%postname%/ but allow authors to still be located at mysite.com/authors/%nicename%?
- get_template_part() – post-meta not working?
- How can I display custom post types under multiple views?
- Automaticly add slug to posts
- Filtering by Post Meta Custom Fields – Performance
- Change headers in admin posts list
- Custom post type, permalinks & pagination, going wrong
- In WordPress how do you create a custom post type with the author’s name in the slug?
- Filter post by current 2 differents users id
- get_the_terms return only last term
- Query custom post type only if it contains another custom post type
- Access $post object when adding custom columns to list table
- Custom template with CPT doesn’t display on frontend
- How do I get array of types associated with a taxonomy?
- Custom template page with custom archives listing by user
- Show category ID on custom post type
- Unable to get post archive link
- How to call in Custom Post-Type Categories?
- Isotope Filtering with Bootstrap Tabs – Custom Post Type Query Loop in each Tab (Have to click twice to filter)
- Child post with numeric only slug keeps redirecting to parent
- Should wp_postmeta meta_key always be unique for a given post_id?
- creat filter with wp_query
- Are pages consuming more server resources than posts?
- Possible to add different google analytics in custom post type?
- What is the best practice for displaying my plugin content in themes?
- Portfolio Page for Classic Posts
- next/previous links on custom post single a little screwy
- Archive for a Taxonomy of a Custom Post type
- Including all post id’s of a custom post type into an array
- WordPress API for custom post types returns rest_no_route
- Multiple Custom Post Type queries, how to DRY it up
- WordPress app page not found error for posts with hyphen in permalink
- Dump custom post type database
- Create a custom post type for a photo post
- Custom post type and standard post not displaying or working
- Get all post from a post type
- Create a select metabox that the user can pupolate?
- Display custom meta on page that has been check in custom post type
- Custom Post Type Archive template not being called
- How to selected value default in option list?
- Query for bbPress replies to current topic?
- Custom post type and multi taxonomies + customize url
- Redirect Existing Post to CPT
- Grouping custom wordpress post types by acf value
- Get_post_custom not fetching value from array wordpress
- Archive Post Not Showing All Post
- Creating a custom post type upon registration for a specific user role
- WordPress Post ID overwritten when I create a new post?
- Private:Autodraft post created automatically, Is that normal?
- I cannot display custom posts in custom taxonomy
- Publish metabox postition?
- How to change URL structure for custom post type in wordpress? Custom taxonomy + custom Post name [duplicate]
- Custom taxonomy with custom post type template not showing
- Loop to display parent categories in custom taxonomy
- Collect custom post in a calendar
- pagination for a custom query
- CPT Efficient way to display posts from different categories with custom query
- Use Tags to Query Associated Multiple Posts and Get The Average Of Custom Field Values
- redirect old post type url to new structure url
- Displaying wp post categories into my custom metabox
- custom_post_type with umlaut in name
- Advanced search form with filters for custom taxonomies and custom fields
- $wpdb returns no results with SELECT query on custom post type, works on default post type
- current_page_item and custom post type?
- How do I do this?: If custom post type exists, echo it, else do not
- Get Posts From A Certain Post Type In An ID Array
- Custom post type efficiency
- How to display custom message for (Genesis) featured posts if no posts
- One set of categories for multiple custom posts
- sidebar hierarchical menu category & custom post type
- CPT Archive Pagination – Page not found
- Query order by meta value force specific tag first
- Custom post type is_singular condtional not working when managing sidebar display
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?