How to Display Codestar Framework Metabox Field Data

Quick Summary

  • Codestar Framework saves a metabox's fields as one array under the metabox id, so load it with get_post_meta( get_the_ID(), 'metabox_id', true ) and print the field by its id.
  • Check the field with ! empty() before printing it: on PHP 8, reading a key from the empty string returned for a post without saved data is a fatal error.
  • Codestar Framework isn’t actively maintained: 2.3.1 from January 2024 is the latest release, metaboxes need the premium version, and the premium item is no longer available on CodeCanyon.

By default, Codestar Framework saves all the fields of a metabox together: one array in a single post meta entry, whose key is the metabox’s unique id. To show a field in a template, load that array with get_post_meta() and print the field by its id. This works in Codestar Framework 2, where you create metaboxes with CSF::createMetabox(), and in the old 1.x versions that used a metabox.config.php file.

Does anyone still maintain Codestar Framework?

Not actively. As of September 2026, the latest release on GitHub is 2.3.1, from January 2024, and the maintainer hasn’t replied to any issue there since. The official site still lists 2.3.0 as the current version and calls it “WordPress 6.2.x Ready”. Metaboxes are a premium feature: the free version on GitHub only includes the admin options panel, and in it CSF::createMetabox() does nothing. The premium version was on sale on CodeCanyon. As of September 2026, the item page linked from the official site no longer loads, and the author’s CodeCanyon profile shows a farewell message and lists no items.

If your theme or plugin already bundles Codestar Framework, the code below reads its values. For a new project, a maintained custom fields plugin is the safer choice: ACF, Meta Box and CMB2 all had updates on WordPress.org in September 2026.

How to create a metabox in Codestar Framework 2

In version 2 you register the metabox in PHP, in your theme’s functions.php or in the plugin that loads the framework. CSF::createMetabox() takes the metabox’s unique id and its settings, and CSF::createSection() adds a section of fields to it:

PHP
if ( class_exists( 'CSF' ) ) {

    $prefix = '_custom_page_options';

    CSF::createMetabox( $prefix, array(
        'title'     => 'Custom Page Options',
        'post_type' => 'page',
    ) );

    CSF::createSection( $prefix, array(
        'title'  => 'Section 1',
        'fields' => array(
            array(
                'id'    => 'section_1_text',
                'type'  => 'text',
                'title' => 'Text Field',
            ),
        ),
    ) );
}
  • _custom_page_options is the metabox id. It becomes the post meta key that holds all the metabox’s fields.
  • post_type is the post type the box appears on; pass an array for several.
  • section_1_text is the id of one field. You use it to pick the value out of the array.
  • The class_exists( 'CSF' ) check keeps the site running if the framework is missing.
  • Make the calls when your theme or plugin file loads, as here. The framework builds the registered metaboxes on the after_setup_theme and init hooks, so a call made from a later hook has no effect.

How to display the field value

In the template that displays the page, inside the Loop, load the metabox array and print the field:

PHP
<?php
$meta_data = get_post_meta( get_the_ID(), '_custom_page_options', true );

if ( ! empty( $meta_data['section_1_text'] ) ) {
    echo esc_html( $meta_data['section_1_text'] );
}
?>
  • get_post_meta() loads the saved data for the current post. The third argument, true, returns a single value: the array of all fields in the metabox.
  • $meta_data['section_1_text'] picks one field by its id. Replace it with the id of the field you want to show. For repeatable fields, see outputting Codestar group fields in a loop.
  • get_the_ID() refers to the current post, so use the code inside the Loop of the template that displays the page, for example a custom page template such as services-page-template.php.
  • The ! empty() check matters on PHP 8. A page that nobody has saved since you added the metabox has no data, so get_post_meta() returns an empty string, and reading $meta_data['section_1_text'] from a string stops the page with the fatal error “Cannot access offset of type string on string”.
  • esc_html() prints text fields safely. The framework keeps the HTML allowed in post content when it saves a field, so for a field that is meant to hold HTML, such as a wp_editor field, print it with wp_kses_post() instead.

What if the metabox uses data_type unserialize?

CSF::createMetabox() has a data_type setting. The default, serialize, saves the array described above. With 'data_type' => 'unserialize', each field is saved as its own post meta entry named after the field id, so you read the field directly:

PHP
<?php echo esc_html( get_post_meta( get_the_ID(), 'section_1_text', true ) ); ?>

Check the createMetabox() call in your theme to see which one it uses. The framework’s configuration docs show both ways of reading a value.

Things to check

  • If the metabox has a different id, change _custom_page_options to match, otherwise get_post_meta() returns an empty string and nothing prints.
  • A default value in the field settings only fills the field on the edit screen. The framework saves nothing until someone updates the post, so older posts return nothing for that field until then.
  • On PHP 8.2 and later, copies of the framework older than 2.3.1 can print notices such as “Creation of dynamic property CSF_Metabox::$post_formats is deprecated”. Version 2.3.1 marks the framework’s base class with #[AllowDynamicProperties], which stops them.

Codestar Framework 1.x (metabox.config.php)

Sites built on version 1.x define their metaboxes in the framework’s config/metabox.config.php file. Each entry of the $options array is a metabox, and its id is the post meta key. _custom_page_options and section_1_text come from that file’s own sample:

PHP
$options[] = array(
  'id'        => '_custom_page_options',
  'title'     => 'Custom Page Options',
  'post_type' => 'page',
  'context'   => 'normal',
  'priority'  => 'default',
  'sections'  => array(
    array(
      'name'   => 'section_1',
      'title'  => 'Section 1',
      'fields' => array(
        array(
          'id'    => 'section_1_text',
          'type'  => 'text',
          'title' => 'Text Field',
        ),
      ),
    ),
  ),
);

CSFramework_Metabox::instance( $options );

Version 1.x also saves each metabox as one array under its id, so the same get_post_meta() code reads 1.x values. The 1.x line is no longer developed; the official repository only has 2.x releases.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More