Closed fkildoo closed 7 years ago
As a workaround, I was able to edit my archive.php theme file so that the sidebar (containing the widgets) would not appear on those pages. I'd say the problem or bug still exists but this bandaid is good enough for now.
Here's a workaround that works. We can fix this by using add_filter
function.
add_filter( 'widget_display_callback', 'custom_widgetopts_display_callback', 51, 3 );
function custom_widgetopts_display_callback($instance, $widget, $args) {
global $widget_options, $current_user;
$hidden = false;
$opts = ( isset( $instance[ 'extended_widget_opts-'. $widget->id ] ) ) ? $instance[ 'extended_widget_opts-'. $widget->id ] : array();
$visibility = array( 'show' => array(), 'hide' => array() );
//wordpress pages
$visibility = isset( $opts['visibility'] ) ? $opts['visibility'] : array();
$visibility_opts = isset( $opts['visibility']['options'] ) ? $opts['visibility']['options'] : 'hide';
$is_tax = ( 'activate' == $widget_options['visibility'] && isset( $widget_options['settings']['visibility'] ) && isset( $widget_options['settings']['visibility']['taxonomies'] ) ) ? true : false;
if ( $is_tax && is_tag() ) {
if( !isset( $visibility['tags'] ) ){
$visibility['tags'] = array();
}
if( ( isset( $visibility['taxonomies']['post_tag'] ) && $visibility_opts == 'hide' ) ||
( !isset( $visibility['taxonomies']['post_tag'] ) && $visibility_opts == 'show' )
) {
$hidden = true; //hide to all tags
}elseif( isset( $visibility['taxonomies']['post_tag'] ) && $visibility_opts == 'show' ){
$hidden = false; //hide to all tags
}
//do return to bypass other conditions
$hidden = apply_filters( 'widget_options_visibility_tags', $hidden );
if( $hidden ){
return false;
}
}
return $instance;
}
I've made a pull request to this issue.
@pankamilr Thank you very much! Will check and add the fixes on the next update. Thanks again!
Cheers, Jeffrey
I have many of my widgets set to only show on select post type/pages or taxonomy/categories. It is working fine for all the assigned pages and categories, only showing the correct widget on the associated page or category. Having a problem on the tag archive pages. These pages are showing ALL of my widgets.
For example, see this tag archive page that shows all widgets. No widgets should appear. -- http://www.zekiah.com/zekiah_wordpress/tag/arcmap
I thought about making my archive pages full width in my theme files, but that also affects my category pages that need the sidebar.