Forums

[resolved] Dynamic class for widget element (4 posts)

  1. oldcastle
    Member
    Posted 1 year ago #

    Hi,

    I don't know the best way to explain this, so I will try my best.

    Usually we register a sidebar with a code like this

    register_sidebar(
    		array(
    	 		'name' => 'Secondary Widget Area',
    	 		'id'=> 'secundary_sidebar',
    	 		'before_widget' => '<div class="widget">',
    			'after_widget' => '</div>',
    			'before_title' => '<h3 class="widgettitle">',
    			'after_title' => '</h3>',
    		)
    	);

    And when we use it, it will generate this HTML:

    <div class="widget">
    <h3 class="widgettitle">
    ......

    So, my question is. How can I generate automatically a specific class name in my widget?

    The reason is for me to be able to style my widgets easily.

    Thanks!

  2. oldcastle
    Member
    Posted 1 year ago #

    Any help here?

  3. alchymyth
    The Sweeper
    Posted 1 year ago #

    usually, the kubrick default does it with:

    if ( function_exists('register_sidebar') ) {
    	register_sidebar(array(
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h2 class="widgettitle">',
    		'after_title' => '</h2>',
    	));
    }

    have you tried to read the docu:
    http://codex.wordpress.org/Function_Reference/register_sidebar

  4. oldcastle
    Member
    Posted 1 year ago #

    Thank you very much!

    Resolved!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags