• Instead of going into each widget and in the widget-logic field inserting
    is_front_page(), is there a way that I could add some code to my functions.php or other php file so it tells wordpress to only open these widgets on the home page even if it’s not specified in the individual widget?
    Thank you
    Shepard

    https://wordpress.org/plugins/widget-logic/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Great question, I am looking for the same thing. Did you find an answer?

    I’m not quite sure what you have in mind, but you could circumvent the need for WL entirely, but use the same technique it employs. Basically you can filter widgets with

    add_filter( ‘sidebars_widgets’, my_own_filter_sidebars_widgets’, 10);

    and then your function can loop through the sidebars, and each widget in them, unsetting any widget you like and then passing back the result

    function my_own_filter_sidebars_widgets($sidebars_widgets)
    {
    	foreach($sidebars_widgets as $widget_area => $widget_list)
    	{
    		foreach($widget_list as $pos => $widget_id)
    		{
    		…
    		…
    		if (some condition perhaps based on $widget_id)
    			unset($sidebars_widgets[$widget_area][$pos]);
    		…
    		…
    		}
    	}
    	return $sidebars_widgets;
    }

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘php code for template to limit certain pages’ is closed to new replies.