I want a metabox to show only if the post type is 'podcast' OR if the post type is 'post' and a custom field, 'is_ajtd_podcast', is true.
So, in the meta box for the field group 'podcast-fields', I have nothing selected for Location and for "Advanced Location" I have it to show when all conditions match and have custom set to ajtd_show_podcast_fields.
In my functions.php, I've tried many ways to get this to work, but here is my function:
function ajtd_show_podcast_fields($meta_box) {
$show = false;
$post_id = isset($_GET['post']) ? $_GET['post'] : null;
if($post_id != null)
{
$pts = array('post','podcast');
$pt = get_post_type($post_id);
$is_podcast = get_post_meta($post_id, 'is_ajtd_podcast', true);
if ($pt == 'podcast' || ($pt == 'post' && $is_podcast = true)) {
$show = true;
}
}
return $show;
};
This doesn't seem to do anything as the custom fields show up no matter what.
I've tried a variation based on https://docs.metabox.io/filters/rwmb-show/
and had the same logic, but the filter as:
add_filter( 'rwmb_show_podcast-fields', function( $show, $meta_box )
However, when I tried to add that to functions.php, it would throw an error.