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

Meta box with front-end styling

You don’t need a checkbox, you can code one if you want, but you can use the default Custom Fields.

Make sure they are enabled:

enter image description here

Then add some data on the posts you want to have a specific style on, you will need to add this to each post you want to have set to display: none;:
enter image description here

Now inside the loop of your page you will add that value as a CSS class:

 // loop starts
 <?php $authoryes = get_post_meta( get_the_ID(), 'authordisplay', true ); ?>
 <div class="page<?php echo $authoryes; ?>">
 // rest of the loop
 </div>

So now you just have to add one style to your CSS for .pageauthor

You should probably use a more unique name than “author” for the value, I did this fast.

Related Posts:

  1. Display a post count from a custom metabox selection
  2. How do I remove all the metaboxes for a custom post type?
  3. Get all posts from custom post type and insert in select input as metabox
  4. Detect meta value changes when post is updated (post_updated)
  5. Creating a custom post type upon registration
  6. Having trouble with custom post type / meta box
  7. How can I include meta box content when searching?
  8. update a post meta from a single table cell TablePress
  9. update custom post type meta from a shortcode
  10. Custom Meta Boxes – Nonce Issue – Move to trash issue
  11. Displaying Meta Box Image
  12. How to keep a check box in custom meta box for custom post type checked by default for add new post?
  13. How to add multiple featured image in meta box in post editor?
  14. Show metabox in custom-post-template depending on taxonomy term?
  15. Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
  16. Displaying custom posts only if custom meta box’s date is not expired
  17. Displaying Metabox value (custom post type taxonomy)
  18. How can I display my custom metaboxes on a custom post template?
  19. Meta Box Only in CPT Edit Page, Not in Add New
  20. get_post_meta is returning image id
  21. Populate Custom Fields in a Custom Post Type?
  22. Custom meta box data array: foreach not working correctly?
  23. Undefined Variable – Custom Post Type Meta
  24. how to delete all users and posts based on ‘user_meta’?
  25. Populate dropdown from one custom post type inside another custom post type
  26. How to check if user meta field is empty in conditional else statement
  27. A better way to add a meta box to custom post types
  28. Restrict Access to Posts based on Custom User and Post Meta Data
  29. Metabox not show in categories custom post type cmb2
  30. Show Custom Post Type meta boxes only on Page Edit
  31. Can’t publish custom post type – “You are not allowed to edit this post.”
  32. Meta Data for Custom Post Type not saving
  33. create custom meta box with default value
  34. Displaying a div from an assigned meta_value when on a page
  35. How to Echo Metadata Value in Currency Format
  36. Issue on Working with Metabox – Checkbox to enable Sale Items
  37. Why do I have to press the “Update” button twice to save my meta box values?
  38. Values from meta-box not on $_POST
  39. Custom post type suddenly stoped working after WordPress 5 update
  40. How can I output WPAlchemy repeating fields meta values in my page template?
  41. Meta box data is saved but NOT displayed in the meta box text field. Why?
  42. Save Metabox Custom Field Value
  43. Meta box data not saving
  44. WP_Meta_Query object with conditionals
  45. Related posts meta_query CPT
  46. Sanitaizing Select Optin For Custom Post Type Metabox in WP
  47. How to retrive Custom Post Type Meta Fields in Custom WP_Query
  48. Cannot Save MetaBox Data in Custom Post Type
  49. Add a class to post_class if more than one post shares same meta_value_num
  50. Function to return values from metabox
  51. Add a meta field to the list of results for a custom post type
  52. Empty meta-box returns publishdate if no value is set?
  53. Custom Meta Box with variable number of fields
  54. Custom Post Type meta data getting deleted on bulk editing taxonomies
  55. Creating a custom post type upon registration for a specific user role
  56. Get meta values from parent post and save in child post
  57. Metaboxes in Loop
  58. Custom meta box data not saving
  59. Collect custom post in a calendar
  60. Delete custom post type metadata without deleting the post in admin area
  61. Problem with ‘save_post’ hook not running
  62. Edit post meta direct from post.php?
  63. Howto: use existing post_meta as options for a different metabox (checkboxes or list)
  64. Post AND page parameter for WP function
  65. How to display Author Profile based on Custom field value
  66. Use a Variable in update_post_meta as the $meta_key
  67. Repeatable Fields Metabox with Textarea (or wp_editor)
  68. How to use TinyMCE Editor for one of my custom post meta field?
  69. Display correctly using metabox.io
  70. Create Connection Between two post types
  71. pre_get_posts for custom page builder meta box
  72. Disable closing on metaboxes
  73. Update database from Quick Edit according to Checkbox state of Custom Post Type
  74. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  75. Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
  76. Dynamic Custom Fields
  77. Query posts based on the meta key values of logged-in users?
  78. Cannot save CPT meta box
  79. How to make custom taxonomy into drop down select in a custom metabox
  80. Adding Page Templates to post but it ignored it
  81. Parent Page and Breadcrumb URL’s for Custom Post Types Not Working
  82. Create a Dropdown from Custom Post Type
  83. Translating custom post type metaboxes [closed]
  84. Adding a metabox on a CPT’s submenu page
  85. Custom filter function not working with Custom post type
  86. Fixed values for same post translations
  87. How to Add multiple instance of meta box to custom post type
  88. Using POST method in meta box, no results
  89. meta box on custom post type
  90. Checking if $_FILE isset for an array of file upload metaboxes
  91. Importing Data from a Non-WordPress database, into WP
  92. Ordering values entered in Custom Taxonomies
  93. Getting thumbnails of a custom posts featured images in a page-templates metabox
  94. Listing custom terms in custom post meta
  95. Permalinks: custom structure for taxonomy – tags?
  96. List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
  97. Custom Post Type & Meta Box – Displaying meta box information on front end?
  98. Remove Post Custom Meta Box
  99. How can I move (or create another) publish button?
  100. Wrap meta boxes & data handling for specific post types in classes?
Categories custom-post-types Tags custom-post-types, metabox, post-meta, user-meta
Does this function wp_get_nav_menu_object check if a nav menu exists or is supported?
Sorting the portfolio by an ACF? [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