Forums

[resolved] how to set a specific ID to a widget ? (4 posts)

  1. VaN.dev
    Member
    Posted 1 year ago #

    Hello everyone,

    I'm new to WordPress. I'm using v3.0.4, with Aparatus Theme, and installed "Sidebar Login" and "Social Profiles" plugins.

    Now, i'd like to stylize their appearance in the sidebar. But when I look at the code, it give something like this :

    <div class="sidebar-row">
    	<h3>Follow us on :</h3>
    	<a href="http://www.rss.com"><img src="http://cluster010.ovh.net/~paconlin/wp-content/plugins/social-profiles-widget/images/default/Feed_48x48.png" alt="RSS" /></a>
    	<a href="http://www.viadeo.com"><img src="http://cluster010.ovh.net/~paconlin/wp-content/plugins/social-profiles-widget/images/default/Viadeo_48x48.png" alt="Viadeo" /></a>
    	<a href="http://www.linkedin.com"><img src="http://cluster010.ovh.net/~paconlin/wp-content/plugins/social-profiles-widget/images/default/Linkedin_48x48.png" alt="Linkedin" /></a>
    	<a href="http://www.twitter.com"><img src="http://cluster010.ovh.net/~paconlin/wp-content/plugins/social-profiles-widget/images/default/Twitter_48x48.png" alt="Twitter" /></a>
    	<a href="http://www.xing.com"><img src="http://cluster010.ovh.net/~paconlin/wp-content/plugins/social-profiles-widget/images/default/Xing_48x48.png" alt="Xing" /></a>
    </div>

    So WordPress just gives to the widget a generic class, but no ID. Then I can't put specific style to this plugin.

    In that case, how can I put a specific style to my plugin ?
    Any help would be appreciated.

    Greetings,
    VaN

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    http://codex.wordpress.org/Function_Reference/register_sidebar

    You will want to look at how your sidebar is registered in functions.php

    then note this line in that link I posted

    <li id="%1$s" class="widget %2$s">

    you can make use of the %1$s and %2$s to get unique IDs in your own code

  3. VaN.dev
    Member
    Posted 1 year ago #

    Thank you Rev.Voodoo.

    Took me some time to understand what you were talking about, but finally I did it.
    I changed my register_sidebar() function to this :

    register_sidebar(array('name'=>'sidebar',
    'before_widget' => '<div id="%1$s" class="sidebar-row widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
    ));

    I wanted to keep it as a DIV element, instead of a LI. No problem with that way of building widget container ?

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    Nope, no problem.... I actually prefer DIVs myself. Glad you figured it out!

Topic Closed

This topic has been closed to new replies.

About this Topic