• Resolved ramzesimus

    (@ramzesimus)


    Hi Andrei,

    Is there any option to change markup for widgets inside the area created by the plugin?

    Best Regards!
    Ramzesimus

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Andrei Surdu

    (@_smartik_)

    Hi.
    The markup is inherited from the sidebar that is replaced.
    To change the markup directly for generated sidebars that does not replace other sidebars you can do this:

    
    add_filter( 'dynamic_sidebar_params', function( $args ){
    	$option    = get_option( 'smk_sidebar_generator', array() );
    	$generated = !empty( $option['sidebars'] ) ? $option['sidebars'] :array();
    
    	if( ! array_key_exists( $args[0]['id'], $generated ) )
    		return $args;
    
    	$new_args = array(
    		'before_widget' => '<div id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</div>',
    		'before_title'  => '<h3 class="widget-title">',
    		'after_title'   => '</h3>'
    	);
    
    	$new_args = wp_parse_args( $new_args, $args[0] );
    
    	$args[0] = $new_args;
    
    	return $args;
    }, 99);
    

    Add this code in theme’s functions.php or in a custom plugin.

    Anyway in version 4.0 I’m going to include an admin panel with an option for this case.

    Regards.

    Thread Starter ramzesimus

    (@ramzesimus)

    Hi Andrei,

    Thanks for your prompt reply.

    You were right that the markup is inherited from the sidebar that is replaced. But looks like there is an issue when I use Visual Composer’s Widgetised Area element. Sidebar displayed properly by widgets have default markup.

    Anyway thanks for you help! ??

    Best Regards!
    Ramzesimus

    • This reply was modified 7 years, 6 months ago by ramzesimus.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to change widget markup?’ is closed to new replies.