By default get_posts()
uses a default post type of post
.
If you want to select from a CPT then you need this:
$myposts = get_posts('numberposts=4&offset=1&category=3,4&post_type=YOUr_CPT_HERE');
Related Posts:
- Reducing the use of global $post
- Multisite Global Custom Posts
- How does the $post_type global variable work?
- Using global $post; to get featured image for custom post via WP_Query
- Assign External Database Queries to Global Variables and Make Them Accessible
- Global $post shows null in some of my custom post types archive pages
- Does WP have a global of $id?
- Using global $post; with custom post types
- Popup panel is only displaying 1 entry ignoring all others
- How do I set the default admin sort order for a custom post type to a custom column?
- Delete all posts of a custom post type—efficiently
- Create category only for custom post type
- Custom Post Types not showing on Custom Taxonomy archive page
- is_singular() not working if called via callback function of admin-ajax.php
- Search everything (posts, pages, tags, cpt, meta)
- Reslug a Custom Post Type
- Removing CPT slug from URL results in 404 error for archive page
- front end radio custom taxonomy with custom post type
- Search Post Title Only [duplicate]
- Custom post type’s slug gets wrong when adding a custom meta box
- Displaying Meta Box Image
- Beginner question: Accessing functions.php through admin web interface in order to import custom post types?
- How can i list custom post type categories?
- Query Custom Post by Category
- Custom post type routing with hierarchy
- Role Capabilities: Add New Ones?
- Sub-Sub-Blogs — creating and importing content into a custom sub-type
- Custom post type capabilities require “create_posts” to access the edit posts list page
- Custom post type with slug for plural (archive) and for single
- Custom post type archive not regarding ‘posts_per_page’ => -1
- If post_type is This or This
- Add category in post type dynamically
- Shortcode insertion in tab
- Group custom posts by custom taxonomy names
- Using GraphQL Plugin with Pods Framework
- Use regular category with custom post types
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- Custom Post Types don’t highlight in menu nav
- Custom post type getting wrong categories and tags
- How to Create an Image Upload Box for Custom Posts?
- How to filter wp_list_categories output with some custom post type meta query?
- Callback to custom field is not working in WordPress REST API
- Query Post Object in WP Admin
- delete_published_posts does not work
- Users create/join groups
- Next Post links not working in custom post type shortcode
- how to determine we are in add new custom post type or edit custom post type
- custom comments form for custom post type
- Single custom post type’s menu ancestor/parent is Posts archive page
- Want to be able to sign up subscribers as authors
- WP the_posts() on single-cars.php get category link
- tax_query not working in template
- Custom Post Type Dilema – How do I categorise by country?
- Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Exclude current post for custom post type
- Publish and save specific postmeta to a filtered post_type
- how to associate several authors to a custom post type
- How to include category name/id in wp_query for retrieving “custom post type” from a particular category?
- Which file/template is in charge of taxonomies for custom post types?
- Address as a content type post
- Using menu_position to add two entries between Dashboard and Posts
- How to manage selected post-formats in custom post type
- Remove default WYSIWYG editor without removing custom fields editors
- File sharing platform for user contributions? [closed]
- List All Custom Post Types Posts in Nav Menu Dynamically
- how to get options to choose post format in add new post
- Update ACF fields on a frontend form? [closed]
- Page-CPT.php redirects to archive or single.php
- Sanitaizing Select Optin For Custom Post Type Metabox in WP
- Printing errors during save custom post type
- How to setup a permalink structure for a custom post type
- Loop and add Specific Categories and Products Images
- Is possible register two archive pages for single custom post type?
- Include “Scheduled” (“Future”) Posts in WordPress Post Navigation ( previous_post_link, next_post_link ) for a Specific Custom Post Type
- Custom Post Type with Different Sets of Post Content?
- Add a class to a div if custom post type has specific terms?
- Custom post type paging return home page
- Custom taxonomy returns 404 even with saving permalinks
- Where is get_post_meta value located?
- 2 modal windows with ACF content on Archive page
- Custom post type single page uses the right template in preview mode but shows a different template after being posted
- Custom Post Type works when registered in functions.php but not when registered in plugin
- Custom Post Type – Display all, wrap in groups of 3
- Showing Custom Post Type with his templates on a custom page template
- Get name CPT with slug taxonomy
- How to pass modified post to RSS feed?
- Custom post edit page permalink links to edit page rather than the post
- How to mark posts as visited
- get children from current variable (taxonomy) via shortcode
- Show Templates in Custom Post Type Editor
- Custom Post Type as invoice or order template
- How can I make a custom post type that loops pages in a new dashboard page, each single page is a new dashboard page (all within the back-end)?
- How can you preserve URLs when moving posts to a custom post type?
- Two blogs on same WP website
- Pagination not working for archive
- Save post_parent in a custom post type
- How to add to taxonomies to a post type
- Custom plugin contact form connecting to mailchimp API
- Update Custom Field daily within 7days