WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic Widgets
[resolved] Set dynamic widget to display widget area only on active pages/posts (4 posts)

  1. ResaMichelle
    Member
    Posted 1 year ago #

    I'd like to make a widget area display only on the pages/posts/category archives on which a widget is active. How can I accomplish this? Thus far, I have this in my functions.php but it's not sufficient.

    function child_before_posts_sidebar() {
    
    	if (is_active_sidebar() ) {
        echo '<div class="before-posts-sidebar">';
            dynamic_sidebar( 'before-posts-sidebar' );
        echo '</div>';
    	}
    	else {
    	echo '';
    	}
    
    }

    Thanks!

    http://wordpress.org/extend/plugins/dynamic-widgets/

  2. Qurl
    Member
    Plugin Author

    Posted 1 year ago #

    Dynamic Widgets shows or hides widgets based on the rules you've set in the DW options. This question goes way beyond that and is in my opinion not a support question about DW.

  3. ResaMichelle
    Member
    Posted 1 year ago #

    But you see, it is a dynamic widget issue because that particular sidebar IS active, yet it still does not display the widget where it should display. I was able to resolve this by other means, but to be clear, when dynamic widgets is active, or a widget is dynamic, the widget area does not register as active. Just a heads up.

  4. Qurl
    Member
    Plugin Author

    Posted 1 year ago #

    When a sidebar becomes empty due to rules you've set in DW, the sidebar becomes inactive. Also, as far as I know is_active_sidebar() needs an index parameter.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic