is there any way to have custom post meta+html not output if the box is blank?
I'm bit of a php newbie and have been reading up on it, but i have tried 'undefined' as well as 'null'. Also tried: if (isset($embed)), but probably did it wrong? None seem to work.
if ($embed != null) {
echo '<div id="slide"><iframe title="YouTube video player" width="424" height="348" src="http://www.youtube.com/embed/';
echo get_post_meta($post->ID, "embed", true);
echo '" frameborder="0" allowfullscreen></iframe></div>';
}
here is portion of functions.php that has the embed code for custom post meta:
add_action('init', 'package_register');
function package_register() {
$args = array(
'label' => __('packages'),
'singular_label' => __('package'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type( 'package' , $args );
}
add_action("admin_init", "admin_init");
add_action('save_post', 'save_embed');
function admin_init(){
add_meta_box("prodInfo-meta", "package Options", "meta_options", "package", "side", "low");
}
function meta_options(){
global $post;
$custom = get_post_custom($post->ID);
$embed = $custom["embed"][0];
echo '<img src="http://www.address.com/wp-content/themes/slideshow/images/vimeo.png"><br /><label>embed:</label><input type="text" name="embed" value="'. $embed .'" />';
}
function save_embed(){
if(isset($_POST["date"]))
update_post_meta($post->ID, “horario”, $_POST["date"]);
global $post;
update_post_meta($post->ID, "embed", $_POST["embed"]);
}
// custom table columns
register_taxonomy("catalog", array("package"), array("hierarchical" => true, "label" => "Catalogs", "singular_label" => "Catalog", "rewrite" => true));
also anyone know if custom post meta can store html? seem to have some issues with it storing html, but alpha-numeric numbers seem to work fine.