Here is a simple example that adds a meta box to all public post types:
// All public post types
$post_types = array_merge(
array('page' => 'page', 'post' => 'post'),
get_post_types(array('_builtin' => FALSE)),
);
// Add meta box for each post type
foreach ($post_types as $post_type)
{
add_meta_box('id', 'title', 'callback', $post_type);
}
WP Codex: get_post_types()
, add_meta_box()
.
Related Posts:
- How to get images from EDD post?
- Accessing post’s meta data based on user’s click of a post
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- Redirect to another page using contact form 7? [closed]
- How to delete all trashed item in one-go
- Finding the screen id of a page generated with add_menu_page
- WordPress custom taxonomy not showing
- 2 wordpress site same database
- “Allowed memory size” problem [closed]
- How to create repeater field manually, without plugin (ACF Pro)?
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- How to get the custom field value using SQL query
- How to arrange custom posts in the backend/admin by custom taxonomy
- Problem with checked box on wp car manager plugin
- WordPress hide post from custom post-type on a single page
- Calling an custom field from theme option at the frontend
- WordPress User Frontend Editing Custom Fields
- public custom posts not showing in my wordpress plugin
- Disable email notification after change of password
- How to get a variable number of posts per post type on the main loop?
- Run WP-CLI using PHP
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Plugin update error message
- PHP Deprecated: Non-static method should not be called statically
- Set a User as Author of all ‘New Posts’ posted
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- Add .html extension to custom post type taxonomies
- Calling function from within functions.php returns unwanted value
- How to get the custom page get_permalink?
- White text on white background in TinyMCE when wp_editor is called in WP 3.9
- Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
- Loading class files via autoload method
- Plugin “Meta Box”: Implementing meta boxes in custom post type
- Adding a custom line of text to php code
- plugins_url() incorrectly returns a url with www subdomain
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Plugin allowing for artists, events and venues
- Disable Other Plugins on my Custom Post Type?
- Getting media library popup in custom plugin admin page
- How to add pagination to wpbakery grid?
- Escape when echoed
- add_meta_box (Will display only in specific page admin WordPress)
- How to write one comment and publish on every post using database or plugin?
- Why wp_mail() function isn’t sending any emails and displaying ‘0’ in Chrome ‘Network’ response
- How can I display a contact form for out of stock products in WooCommerce?
- How to get number of Affected rows from wordpress dbDelta() function
- RW Meta Box ,Problem setting post title
- Redirecting to home page after login as custom role WordPress
- WooCommerce Custom Product to checkout
- How to stop or remove an action being called inside a function of an extended class
- How to simultaneously access the same MySQL database in the main column and sidebar of WordPress?
- Date calculations from 2 custom fields
- get_post_type on post.php
- Error with Image Slide plug-in/ s3slider in WP
- Easiest way to add dropdown to a page
- Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
- How to enable specific plugin only based around shop manager role?
- Changing “elapsed time” to “time remaining” on MP3-jPlayer audio player with CSS or PHP changes
- Adding a new field to the address field type in gravity forms
- Show admin notice on incorrect value on form field
- WordPress adding a menu page when activating a plugin
- Is there a function to list all uploaded images? How can I add one?
- Sticky option for custom post types without using custom fields or plugins
- speed up pagination for huge database
- Using meta_query in a WP_Query not working for numbers properly
- What hook can I use to modify custom post data before it is displayed on the page?
- WP Insert Post If user refreshes override new post
- Code for unique user visit count on every page WordPress
- Searching a tab/space delimited text file based upon form criteria and returning a ‘record’ into a word press results page
- Register PODS Custom Field with WPGraphQL [closed]
- WordPress is redirecting me to homepage
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Redirect to a page while maintaining search query parameters without causing an infinite loop
- How to ignore fields if empty?
- Moving a few select DB tables to a new WP instance
- Cron job shedules replace?
- Create a form and have custom menu display based on user answers?
- Set a template on a custom post in the plugin
- How to get the total count of Favorite/Favorited authors
- Admin login substantially slower on production server
- Problem with conditional woocommerce custom checkout field
- Show custom taxonomy not in submenu
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Editing Global Variables from Inside Functions
- Posting code inside the post instead of in the template file using shortcode
- conditional tags for the output of a plugin
- Can’t insert files in other inputs
- How to list the categories by custom taxonomy created?
- How do I output user_registered time in my correct timezone?
- How to tweak a plugin without preventing it from updating
- Place max_execution_time in plugin [closed]
- Creating a press page for our project
- how to search through plugin in wordpress cimy-user-extra-fields?
- wordpress illegal string offset ‘parameter’ error
- Translate text for empty product
- Filter custom post type returned from REST api
- Function not being called on form submit, only blank admin-post.php page
- WordPress Convert queries to slashes using function.php
- Failed to update a post when I add a taxonomy to it
- plugin doesn’t retrieve data from database