• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to move a metabox above the main content?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to move a metabox above the main content?

This topic is: resolved

Tagged: cmb2, Custom fields, hooks, metaboxes

  • This topic has 1 reply, 1 voice, and was last updated 11 years, 2 months ago by studionoobly.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 16, 2015 at 4:40 am #159538
    studionoobly
    Member

    On a template page I have a metabox that I can get to show up below the main content of the page but now I would like to move the metabox to display just after the "content-sidebar-wrap"?

    <?php
      /*
      Template Name: Custom Page Template
      */
      /*
      This is the Custom page template
      */
      // force page layout to be content then sidebar
      add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
      // remove comments
      remove_action( 'genesis_comments', 'genesis_do_comments' );
      // adding a custom sidebar for this page
      remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
      add_action( 'genesis_sidebar', 'nb_do_sidebar' );
      // inserting custom page content into genesis template
      add_action( 'genesis_after_entry', 'nb_custom_page' );
      // creating custom page content
      function nb_custom_page() { ?>
    
          <?php
            $textarea = get_post_meta( get_the_ID(), '_cmb_c_textarea', true );
          ?>
    
          <p><?php echo esc_html( $textarea ); ?></p>
    
    <?php
    }
    // do genesis
    genesis();
    ?>

    I have tried adding the following but the metabox disappears on the front end with no error message?

    <?php
            $textarea = get_post_meta( get_the_ID(), '_cmb_c_textarea', true );
          ?>
    
          <?php 
            add_action( 'genesis_before_content', 'nb_do_metabox' );
            function nb_do_metabox() {
              echo esc_html( $textarea ); 
            }
          ?>

    Thanks.

    July 16, 2015 at 7:32 am #159557
    studionoobly
    Member

    After much banging of head against desk, I found this solution worked for me, I'm not sure if it's the best way of doing it, if anyone has a better idea I'm all ears.

    <?php
      /*
      Template Name: Custom Page Template
      */
      /*
      This is the Custom page template
      */
      // force page layout to be content then sidebar
      add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
      // remove comments
      remove_action( 'genesis_comments', 'genesis_do_comments' );
      // adding a custom sidebar for this page
      remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
      add_action( 'genesis_sidebar', 'nb_do_sidebar' );
    
      // adding two custom fields before the page content
      add_action( 'genesis_before_content_sidebar_wrap', 'nb_meta_box_callback' );
      if (!function_exists('nb_meta_box_callback')) {
        function nb_meta_box_callback() {
      // Grab the metadata from the database
          $text = get_post_meta( get_the_ID(), '_cmb_text', true );
          $textarea = get_post_meta( get_the_ID(), '_cmb_textarea', true );
      // spit out the metadata in two custom fields
          echo '<h1 class="entry-title">' . esc_html( $text ) . '</h1>';
          echo '<div class="entry-intro">' . esc_html( $textarea ) . '</div>';
        }
      }
    
      // inserting custom page content into genesis template
      add_action( 'genesis_after_entry', 'nb_custom_page' );
      // creating custom page content
      function nb_custom_page() { ?>
    
    <!-- you can place aditional page content here -->
    
    <?php
    }
    // do genesis
    genesis();
    ?>
  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘How to move a metabox above the main content?’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble