• 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 get CMB working within a plugin?

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 › General Discussion › How to get CMB working within a plugin?

This topic is: resolved

Tagged: cmb, metabox, plugin

  • This topic has 1 reply, 1 voice, and was last updated 11 years, 2 months ago by Posh John.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 3, 2014 at 7:07 pm #93296
    Posh John
    Participant

    I am in the process of moving my CPTs to a core functionality plugin (my first plugin yay!)

    I am having trouble getting my metaboxes to work within my plugin - i'm using the CMB files.

    Usually with my /lib/metabox folder inside my theme it works, but i can't figure out how to move all this to the plugin. When i was building my cpt within my theme i had this in my cpt file >

    // Initialize the metabox class
    add_action( 'init', 'be_initialize_cmb_meta_boxes', 9999 );
    function be_initialize_cmb_meta_boxes() {
    	if ( !class_exists( 'cmb_Meta_Box' ) ) {
    		require_once(CHILD_DIR . '/lib/metabox/init.php');
    	}
    }
    

    Now i am doing it from within my plugin, I tried changing the "require_once" line to the following >
    require_once( plugin_dir_url(__file__) . 'lib/metabox/init.php' );

    ... but get the white screen of death! What am i doing wrong?


    Thus the heavens and the earth were completed in all their vast array. Genesis 2

    March 4, 2014 at 5:41 pm #93443
    Posh John
    Participant

    Figured it out!

    For anyone that's interested, the "require_once" line should have been >

    require_once( plugin_dir_path(__FILE__) . 'lib/metabox/init.php' );

    Cool - i just built my first plugin 🙂


    Thus the heavens and the earth were completed in all their vast array. Genesis 2

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 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