Global variable of Metaboxes
-
I am learning WordPress Plugin Development. My Code is like below.
class Admin { public function __construct() { add_action( 'admin_menu', [$this,'news_meta_boxes'] ); } public function news_meta_boxes() { add_meta_box('news_settings', 'News Settings', [ $this, 'post_settings_html' ], 'news', 'normal', 'default'); add_meta_box('display_settings', 'Display Settings', [ $this, 'display_settings_html' ], 'news', 'normal', 'default'); add_meta_box('style_settings', 'Color Settings', [ $this, 'style_settings_html' ], 'news', 'normal', 'default'); } public function post_settings_html($post) { $stored_meta = get_post_meta($post->ID); // I would like to use it globally as like member variable // more code here } public function display_settings_html($post) { $stored_meta = get_post_meta($post->ID); // I would like to use it globally as like member variable // more code here } public function style_settings_html($post) { $stored_meta = get_post_meta($post->ID); // I would like to use it globally as like member variable // more code here } }
How can I use
$stored_meta = get_post_meta($post->ID);
globally like member variable ?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Global variable of Metaboxes’ is closed to new replies.