You can make an array of the post types you don’t want and then check in_array()
to see if they match before you output anything with them.
<?php
//You'll want to get at the actual name for My Templates.
//My attempt is just a guess.
$types_array = array( 'attachment' , 'elementor_library' );
$types = get_post_types( ['public' => true ], 'objects' );
foreach ( $types as $type ) {
if( !in_array( $type->name, $types_array )) {
if ( isset( $type->labels->name) ) {
echo $type->labels->name . '<br>';
}
}
}
?>
Related Posts:
- Use register_post_type() to modify an existing post type
- Custom post type pagination 404 fix?
- Per Post Type Revision Numbers
- Get list of all registered post types slugs
- WP_Query ignores post_type in category view
- How do I implement custom fields without using any plugins?
- custom post types don’t appear in RSS
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- Registered Post Type Isn’t Showing in Admin Menu
- Multiple post type queries (with specific arguments for each)
- How to retrieve a custom post’s capability?
- Use get_post_types to query only custom posts types
- WP_Query | ‘post_type’ doesn’t work
- child of post type (custom)
- How do I set default meta value by post type?
- Limit amount of posts made within a custom taxonomy
- Incorrect post_type in url of taxonomy term
- How to define which register_post_status goes to which register_post_type?
- Is it possible to filter the display name for post formats for display in the Formats meta box?
- get_the_post_thumbnail_url(‘full’) returns empty from custom post type
- single-{post_type}.php not working
- How to Set Taxonomy Object Description?
- Show only public custom posts in home page
- Can I change my post type to anything and my site still work?
- post_parent in custom post type
- Custom filter for main search: how to exclude specific post_type from search results
- get_post_types – exclude multiple post types by name
- Remove taxonomies using register_post_type_args
- Custom post type and standard post not displaying or working
- post_type internal ID?
- Dynamic pages for linked categories and content
- Custom post type in theme not appearing
- How to copy a custom field from the user’s CPT to the user’s normal posts
- get_post_types not working properly in admin
- Add filter to Admin list for all custom post types by their custom taxonomies
- Post Type => Any conundrum
- How to hide list from custom post type
- Why is my custom post content only viewable when signed into WordPress?
- Custom Post Type Single Page is not working
- Get all post types that supports tags
- custom post type single page not found after aotumatic publish By the author’s robot
- Custom post type single with custom URL structure
- How to mix 2 kinds of post types
- Change Custom Post Type to Post + Category
- Shortcode in excerpt
- How can i order my posts by post type?
- Permanent Custom Post Type
- Custom post type post_type_link gives “page not found” on any other custom post type
- How to set a default CPT template and create post attribute´s display rules?
- Post types showing tables…Can I do that?
- custom post permalink
- do action inside a class is not working
- Updated from 3.8 to 4.2 and all post types changed to “post”
- Pulling in Related Posts based on Post Type array
- How would I get a list of posts from a custom post type
- 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)?
- Why does ‘exclude_from_search’ exclude a custom post type from WP_Query?
- How to add post type in masonry posts elementory widget
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- custom taxonomy not return in the code
- Custom post type REST api 404: Updating failed. No route was found matching the URL and request method
- How do test if a post is a custom post type?
- Where to put my code: plugin or functions.php?
- What does this PHP function code mean? [closed]
- Remove slug from custom post type post URLs
- How to disable the single view for a custom post type?
- Custom post types, taxonomies, and permalinks
- Query all posts where a meta key does not exist
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- How to get all taxonomies of a post type?
- How to sort the admin area of a WordPress custom post type by a custom field
- How to create a custom search for custom post type?
- Deregister custom post types
- Can I assign a template to a custom post type?
- Permalinks: custom post type -> custom taxonomy -> post
- Should I use custom post types or a custom database tables for plugin development?
- Enable revisions for custom post type
- Extending the search context in the admin list post screen
- How do I query a custom post type with a custom taxonomy?
- Adding a Custom Post Type into the menu screen
- Pagination not working with custom loop
- How to Add Tags to Custom Post Type?
- How come Featured Image isn’t showing up in my Custom Post Type?
- Custom Post Type URL Rewriting?
- Add category base to url in custom post type/taxonomy
- Include custom taxonomy term in search
- Is It Possible To Add Custom Post Type Menu As Another Custom Post Type Sub Menu
- Adding ‘menu order’ column to custom post type admin screen
- Capabilities and Custom Post Types
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- what is the correct way to compare dates in a WP query_posts meta_query
- Custom Taxonomy specific to a Custom Post type
- Renaming Custom Post Types and Taxonomies
- List all posts in custom post type by taxonomy
- Redeclare/Change Slug of a Plugin’s Custom Post Type
- Allow member to have access to custom post type only. Permission to only edit their own posts
- Mixing custom post type and taxonomy rewrite structures?
- Advanced search form with filters for custom taxonomies and custom fields
- Highlighting wp_nav_menu() Ancestor Class w/o Children in Nav Structure?