Ok, with the use of this ‘plugin’ (JareDatch). It works like a charm.
add_filter( 'cmb_meta_boxes', 'cmb_sample_metaboxes' ); /** * Define the metabox and field configurations. ** @param array $meta_boxes * @return array */ function cmb_sample_metaboxes( array $meta_boxes ) {
// Start with an underscore to hide fields from custom fields list
$prefix = '_cmb_';
$meta_boxes[] = array(
'id' => 'appstore_link',
'title' => 'App Store',
'pages' => array( 'apps', ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
array(
'name' => 'App Store',
'desc' => 'field description (optional)',
'id' => $prefix . 'app_store_link',
'type' => 'text',
),
)
);
// Add other metaboxes as needed
return $meta_boxes;}
add_action( 'init', 'cmb_initialize_cmb_meta_boxes', 9999 ); function cmb_initialize_cmb_meta_boxes() {
if ( ! class_exists( 'cmb_Meta_Box' ) )
require_once 'init.php';}
And use the following in your theme:
<?php if ( get_post_meta($post->ID, '_cmb_app_store_link', true) ) : ?>
<a href="https://wordpress.stackexchange.com/questions/72647/<?php echo get_post_meta($post->ID,"_cmb_app_store_link', true) ?>">
<img src="source.png" src="https://wordpress.stackexchange.com/questions/72647/<?php echo get_post_meta($post->ID,"_cmb_app_store_link', true) ?>" alt="<?php the_title(); ?>" />
</a>