I've made a custom post type, with a few accompanying widgets, and I was wondering if it is possible to show (some of) these widgets only if you're on a specific page.
Currently I've got
function widget($args, $instance)
{
global $post;
$links = unserialize(get_post_meta( $post->ID, 'links', true ));
if(!is_singular( 'press_articles' ) || $links == false) {
unregister_widget( 'Point72_Press_Article_Links_Widget' );
return false;
}
// widget stuff
}
But, that doesn't seem to completely remove it, and with that I mean, it removes the widget in the right places, but the positions for the widgets stay even if it's not empty.
So, is there anyway to either remove the empty positions, or not show it at all outside a custom post type?