Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Post AND page parameter for WP function

There’s no reason you can’t call add_meta_box() twice in a row and use the same function to display it both times; just change the $post_type parameter.

Example

foreach ( array ( 'post', 'page' ) as $post_type )
{
    add_meta_box( 'your_id', 'your title', 'your_callback', $post_type );
}

Related Posts:

  1. Detect meta value changes when post is updated (post_updated)
  2. How to change default position of WP meta boxes?
  3. echo value from ‘select’ field type into page template using cmb2?
  4. How do I remove all the metaboxes for a custom post type?
  5. Find callback function for custom taxonomy metabox
  6. Get all posts from custom post type and insert in select input as metabox
  7. Search everything (posts, pages, tags, cpt, meta)
  8. Saving multiple Metabox contents
  9. Having trouble with custom post type / meta box
  10. How can I include meta box content when searching?
  11. update a post meta from a single table cell TablePress
  12. update custom post type meta from a shortcode
  13. Custom Meta Boxes – Nonce Issue – Move to trash issue
  14. Displaying Meta Box Image
  15. How to: add option to add more checkboxes on custom post type
  16. How to keep a check box in custom meta box for custom post type checked by default for add new post?
  17. How to add multiple featured image in meta box in post editor?
  18. Show metabox in custom-post-template depending on taxonomy term?
  19. Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
  20. Displaying custom posts only if custom meta box’s date is not expired
  21. Displaying Metabox value (custom post type taxonomy)
  22. How can I display my custom metaboxes on a custom post template?
  23. Meta Box Only in CPT Edit Page, Not in Add New
  24. get_post_meta is returning image id
  25. A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
  26. Populate Custom Fields in a Custom Post Type?
  27. Custom meta box data array: foreach not working correctly?
  28. Undefined Variable – Custom Post Type Meta
  29. What’s the difference between same wp functions get_posts(); functions in different form?
  30. Populate dropdown from one custom post type inside another custom post type
  31. How to check if user meta field is empty in conditional else statement
  32. Custom Post Type with Templates using Meta Boxes?
  33. A better way to add a meta box to custom post types
  34. get_post_meta not working on publishing
  35. Anon function and add_meta_box
  36. Metabox not show in categories custom post type cmb2
  37. Show Custom Post Type meta boxes only on Page Edit
  38. Cannot save CPT meta box
  39. Can’t publish custom post type – “You are not allowed to edit this post.”
  40. Global custom meta box
  41. Meta Data for Custom Post Type not saving
  42. Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
  43. custom post type metaboxes not saving
  44. create custom meta box with default value
  45. Displaying a div from an assigned meta_value when on a page
  46. How to Echo Metadata Value in Currency Format
  47. Issue on Working with Metabox – Checkbox to enable Sale Items
  48. Why do I have to press the “Update” button twice to save my meta box values?
  49. Values from meta-box not on $_POST
  50. Custom post type suddenly stoped working after WordPress 5 update
  51. How can I output WPAlchemy repeating fields meta values in my page template?
  52. Meta box data is saved but NOT displayed in the meta box text field. Why?
  53. Save Metabox Custom Field Value
  54. Meta box data not saving
  55. Custom meta box in custom post type not working
  56. WP_Meta_Query object with conditionals
  57. Meta box not appearing in my custom post type
  58. Related posts meta_query CPT
  59. Meta box with front-end styling
  60. Sanitaizing Select Optin For Custom Post Type Metabox in WP
  61. How to retrive Custom Post Type Meta Fields in Custom WP_Query
  62. Cannot Save MetaBox Data in Custom Post Type
  63. Add a class to post_class if more than one post shares same meta_value_num
  64. Function to return values from metabox
  65. Add a meta field to the list of results for a custom post type
  66. Empty meta-box returns publishdate if no value is set?
  67. Custom Meta Box with variable number of fields
  68. Custom Post Type meta data getting deleted on bulk editing taxonomies
  69. Custom attachment function not working in v5.4.2?
  70. Problem with multi checkboxes value in metabox?
  71. Get meta values from parent post and save in child post
  72. Custom Function to redirect singular post if specific meta field is empty
  73. Stored meta from attachment, video length?
  74. Metaboxes in Loop
  75. Custom meta box data not saving
  76. Collect custom post in a calendar
  77. Delete custom post type metadata without deleting the post in admin area
  78. Problem with ‘save_post’ hook not running
  79. Edit post meta direct from post.php?
  80. Howto: use existing post_meta as options for a different metabox (checkboxes or list)
  81. Display a post count from a custom metabox selection
  82. Rich Custom Field for Custom Post type not saving
  83. Use a Variable in update_post_meta as the $meta_key
  84. Questions regarding add_meta_box()
  85. Let users upload image(s) to the post from front end
  86. Foreach loop returning more than one item when querying taxonomy
  87. Function to erase every post from a taxonomy
  88. How can I get some of a posts meta data whilst it is still inserting?
  89. Have custom post type Visibility be private by default, and have radio button also set to “Private”
  90. Redirect to URL if x number of days passed
  91. Advanced custom field – posted fields from custom post type
  92. Adding an extra parameter [string] to my posts’ permalink?
  93. delete duplicate meta_value with same post_id
  94. HM CMB: Post Select Field for CPT ID
  95. Custom post type meta box empty after save
  96. Query Custom Posts – Add To Selection
  97. How to add a class to meta boxes (to customize them in CSS)?
  98. CMB select with data from CPT
  99. Search CPT Title AND Meta
  100. I can’t connect my custom jquery to wp admin
Categories custom-post-types Tags custom-post-types, functions, metabox, parameter, post-meta
Satoshi WordPress Theme – Portfolio SetUp Issues
Free WordPress plugins for membership? [closed]

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress