Checkbox on a meta box using CMB2 Plugin

If i get it right, then you just need to get that value from post meta, and make condition. $image_or_video = get_post_meta($post_id, $prefix . ‘image_or_video’, true); // Option 2 is selected if( ‘custom’ === $image_or_video ){ //Then execute some PHP code }

Remove meta box for specific page

The is_page() conditional relies on the global $wp_query WP_Query object which isn’t set on the edit post page. We have some other options though… If we know the page ID we can test against $_GET: /** * Remove metaboxes * * @return void */ function wpse343020_remove_meta_boxes() { if( isset( $_GET, $_GET[‘post’] ) && 123 == … Read more

metabox wordpress show in frontend

The output is escaped, so it will not display html, try this : just save the value of the src attribute <iframe src=”<?php echo esc_attr__( get_post_meta( get_the_ID(), ‘name’, true ) ); ?>” width=”670″ height=”500″>

metabox with custom post type values

the old way when i say “the old way” i mean my old way of doing this ,like i answered Need Help Finding a WordPress E-Commerce Plugin That Utilises Custom Post Types before about creating relations between custom post types that i used custom fields for that meaning: Author will have two custom fields (book_ids[], … Read more

Metabox saves on Update or Publish, but not on Saving Draft

So you first tried hooking on to wp_insert_post_data and could save the meta data when saving Drafts but not when publishing. Then you tried hooking on to save_post and could save meta data when publishing but not when saving Drafts. The easiest solution would be to hook on to both. add_action(‘save_post’, ‘save_details’); add_action(‘wp_insert_post_data’, ‘save_details’); Edit … Read more

Modules with meta box implementations

I recently published a meta box class named My Meta Box which takes care of most of the metabox creation and data saving and that was forked out of from Meta Box script by Rilwis. Using the class is simple eg: <?php require_once(“meta-box-class/my-meta-box-class.php”); if (is_admin()){ /* * prefix of meta keys, optional * use underscore … Read more

Trying to limit access to custom meta box without success

As @totels says, just apply the condition when you add the box, rather than trying to remove it later (FYI, it’s not working because you call the removal on hooks that fire earlier!) add_action( ‘add_meta_boxes’, ‘assistant_editor_box’ ); function assistant_editor_box() { if ( current_user_can( ‘edit_others_posts’ ) ) add_meta_box( ‘assistant_editor_box’, … ) }

Get all meta boxes values

I tried to use WP_Query and it works fine. <?php $args = array(‘post_type’ => ‘institution’); $the_query = new WP_Query($args); while ( $the_query->have_posts() ) : $the_query->next_post(); $id= $the_query->post->ID; $location = get_post_meta($id, ‘institution_location’, true); echo $location; endwhile; ?>