Support » Themes and Templates » customizing sidebar with javascript adding variable to sidebar tags

  • hi i asked this question in support section but no reply, so trying my luck again…

    Code reference:

    function sidebar_args( $name, $widget_class = 'widget', $title = 'h2' )
    $id = strtolower( str_replace( ' ', '-', $name ) );
    return array(
    'name' => $name,
    'id' => $id,
    >>>Line-1 'before_widget' => '<div id="%1$s" class="'.$widget_class.'%2$s">',
    >>>Line-2 'after_widget' => '</div></span>',
    >>>Line-3 'before_title' => '<'.$title.' class="'.$widget_class.'%2$s" >',
    >>>Line-4 'after_title' => '</'.$title.'><span id="'.$idd.'" >',

    incase of line 1 the %2$s is printing widget-3 (where the number 3 is variable added to it)
    Output HTML>> <div class=”widget-3″ id=”linkcat-9″>

    BUT when i use the same code as in line-3 it outputs <h2 class=”section%2$s”>

    the above code is for sidebars and i want to add an ID on each element which is dynamic grows as the number of h2 section increases in my side bar. so that i can use the ID to use in JS to access each content of h2 element under the span tag section.

    can anybody suggest how to use %2$s or %1$s or add a dynamic id on each of the H2 in sidebar?

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

  • The topic ‘customizing sidebar with javascript adding variable to sidebar tags’ is closed to new replies.