You have to return your formatted array. Change the code like below
function get_posttype_list() : array {
$pt_list = [];
$post_types = get_post_types( array( 'public' => true ), 'objects' );
foreach( $post_types as $pt ) {
$pt_list[ $pt->name ] = $pt->labels->singular_name;
}
return $pt_list;
}
Related Posts:
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- How to Add Custom Taxonomy To Woocommerce Plugin
- Creating a Custom Post Type as a Plugin? Why?
- Quick edit screen customization
- Mini-Site Strategy
- Prevent trash/delete action on specific post types
- Loading custom page template via plugin
- Why The Init Hook For Custom Post Types
- register_taxonomy with multiple object type and update_count_callback
- How often do you need to register_post_type?
- Render a different post/template from within the template_include action?
- How to use a dedicated template for the Custom Post Type from a plugin?
- How to append text to title of Custom Post Type post (without affecting all titles on page)?
- Custom Taxonomy and tax_query Issue?
- Use a textarea for a custom post type
- How to register custom post types in a plugin?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- Custom role capabilities to administrator not taking effect (no plugin)
- How do I include drag-and-drop in a plugin?
- How could I create a ‘private comments’ section on a custom post type?
- How do I alter the position of a Custom Post Type menu item within my plugin admin menu?
- Issue with pre_get_posts on custom post type archive pages
- Get rewrite slug of custom post type in template
- Metadata for a taxonomy – is there any WordPress way of doing this?
- Hook to override title, image and content
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- No posts found – Custom Post Type show_ui
- WordPress multiple custom post types capability conflict in a single menu
- Add Custom Post type menu to another menu in specific location
- Set a CPT slug as a base name for all the taxonomies
- A custom post type in another post type
- Wrap meta boxes & data handling for specific post types in classes?
- WordPress custom post type capabilities issue
- HowTo: Custom Post Type (Meta) to Custom Table
- how to set a WP Plugin’s url
- Custom Empty Results page for my Custom Post Type
- detect your custom post type in WordPress
- Option page’s form doesn’t work
- How to group navigation items in the admin panel
- How can I include active content in a custom post type?
- How to access the thank you page from the single post?
- ajax response not recieving
- Custom Meta Box returns no HTML
- shopping cart plugin development
- CPT to installable Plugin
- how can i show a google map in custom post type
- Most viewed post of custom post type
- filter the_content, custom post type, and wp_query
- Fill custom fields when saving custom post types
- How add column from new table in Custom Post Listing (admin)
- Custom post type page with parameter
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Custom post category name showing empty
- allowing custom user role to access custom post type in wordpress admin
- How to show the post which checkbox is not selected
- Is it possible to get the specific content on the search page?
- Get next and prev item from custom WP_Query and Custom Post Type
- How add Filter by Tags and by categories to custom post type in Gutenberg block
- Error 404 change permalink term custom term taxonomy
- Show a custom post title in another custom post type in Meta box
- Register custom_post_type from static function
- custom post type and user post count shortcode
- How to select meta key in custom database query
- Restrict Custom Post Type to One Item
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- How to seperate posts by categories?
- Insert custom taxonomy into category query
- % encoded URL giving 404 error in WordPress
- Widget area for individual posts (custom post type)?
- How can I load Template file from wordpress plugin
- Which File Populating CPTs in Slug URL
- Custom post type that lets users create a set of posts?
- what file is required to be created in plugin folder in order to show all the post content of a CPT with the help of permalink
- Not Able to Get Custom Post Type in Single and Single-custom-post-type
- How to develop custom URL redirection
- Execute code only after user clicks ‘update’ button for CPT being edited
- Can the wp_posts table have the same slug (post_name) in multiple statuses (post_status)?
- Displaying multiple custom post types in single post type at admin section
- Custom Post Type Audio Content
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update
- Add category slug as class attribute in a link array
- Items By Group added to custom post type
- Custom post types working in functions.php but not in plugin
- Resources to learn OOP for WordPress plugins, custom post types, etc
- Multiple Block Quotes without using HTML
- Set a Custom Post Type as a Homepage
- Need some hints for my own WP theme development
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- Custom Post Type urls not working
- I want to show a list of posts under specified categories
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs
- Custom post type template not loading from plugin
- Redirect to All Custom post types
- I am having a problem with fetching product data in the Gutenberg block editor
- how can i call archive-{post type}.php template from my custom plugins to my theams?
- REST API callback function is not called
- Add taxonomy or category slug to custom post types URL
- Redirection after saving a post
- How to fix post_tags not showing for a CPT in new post for a custom user role?