• Hi all,
    I searched these forums but have not been able to find an answer to this question.
    How can one tell various widgets apart? i.e. I don’t want to have labels appearing above them in my sidebar, but when I want to edit them, I’d like to be able to tell which text widget has which code instead of opening them all and trying to figure it out.
    Is there a way to label widgets for administrative use only?

Viewing 6 replies - 1 through 6 (of 6 total)
  • One solution would be to hide the widget titles using CSS. In you theme’s functions.php file find the section the defines the dynamic sidebar and see what tags are going to be generated around a widget title (or look at your webpage source code). This is typically going to be h2, h3 or h4 tags, depending on the theme. You can change what tags go around the widget title with thi code:

    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h4>',
    'after_title' => '</h4>',
    ));
    ?>

    In the above code h4 tags will go around the widget title, so, we can hide the widget title by adding this code to our stylesheet.

    #sidebar h4{
      display:none;
      }

    The above assumes you sidebar is inside an element with the id of “sidebar”. If its a class instead of an id change #sidebar to .sidebar.

    Hope that helps.

    Aaron

    Thread Starter lutetia

    (@lutetia)

    Thanks, that’s a great help.

    But, say I want the title “Pages” to appear above the list of pages in my sidebar.

    But I’m also using text widgets to place Amazon ad code, a Google search bar, etc.

    In the first case I want the header to remain above the widget; in the second case, I don’t.

    Change this:

    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h4>',
    'after_title' => '</h4>',
    ));
    ?>

    to

    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h4>',
    'after_title' => '</h4>',
    ));
    ?>

    The %1$s will set the title of the widget as the list items id, using this id you can target specific h4 title tags and only hide those. For example

    #archives h4{
    diaplay:none;
    }

    Check the source code of your website in a browser after the page loads and you can see what all the id’s were set to and then just use the css above to only hide h4 tags that fall within those id’s like this:

    #archives h4, #categories h4, #pages h4{
    diaplay:none;
    }

    The above are all just examples. You could also just hide all the h4’s like you did before and then only unhide certain ones

    #sidebar h4{
    diaplay:none;
    }
    
    #amazon h4{
    diaplay:block;
    }
    fbidesign

    (@fbidesign)

    Hi,
    in addition to this topic I have a question:
    we use duplicate textwidgets in one sidebar with widget logic to show dynamic content which works fine.
    We are still looking for a solution to show the widgets in a certain language but that’s my main issue.
    What I do need is to find out some way to enter the same title but with different args which should only show in the admin part.

    To be more precise, its a portal for diffent shops which all have different openingtimes. So I don’t want all the duplicate widgets to be titled “Openingtimes” but openingtimes(name_of_the_store) or something like <!–name_of_the_store–>
    Hope this makes sense & hope someone can help me out.
    Kind Regards
    Franek

    fbidesign

    (@fbidesign)

    “We are still looking for a solution to show the widgets in a certain language but that’s my main issue. “

    should be NOT my main issue

    Just one problem when doing a “display: none” for the widget titles, it doesn’t show it on the front-end but it does in the source code. This can have implications on your SEO efforts. One thing you can do if you use this method is to title your widget with some keywords that will be seen by the bots but still not show for the front-end (although this is not the ideal method).

    What I would really like to see WordPress developers do is to provide a function in “all” widgets to turn on or off the title. I have not seen this yet.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Is it possible to label widgets without name showing on page’ is closed to new replies.