• Resolved Doodlebee

    (@doodlebee)


    This is an odd one, I guess.

    I was wondering if there was some kind of code that could be inserted into the sidebar to list the names of different sections in your site. (Yeah, that’s as clear as mud!)

    Maybe if I’m a bit more specific…

    I need to have certain divs created for my sidebar. Each div has an id that matches the name of the section it’s used for, for example:

    <div id="categories">
    <div class="title">Categories</div>
    category pages list here
    </div>

    <div id="archives">
    <div class="title">Archives</div>
    archive list here
    </div>

    …and so on. Now, I know you can display the title of the blog on pages by putting the following code:

    <?php bloginfo('name'); ?>

    So I was wondering if there was a way to just show the titles listed above…so instead of putting in:

    <div id="categories">
    <div class="title">Categories</div>
    category pages list here
    </div>

    I could alter that by putting in something like:

    <div id="<?php title('name'); ?>">
    <div class="title">Categories</div>
    category pages list here
    </div>

    …that way my div would be named exactly what’s in the title of that section.

    Does that make sense? If so, is there a way to do this?

Viewing 1 replies (of 1 total)
  • Thread Starter Doodlebee

    (@doodlebee)

    Ahhh…nevermind.

    I should have also mentioned this is for the “widgets” I’m putting in the sidebar, so I was trying to figure out how to edit the widget thing to make it do what I wanted.

    Since I also hate it when people post a question, and then post “nevermind” without explaining what they did – I’ll tell you (in case someone else comes along and wonders the same thing):

    I should have *compeltely* read the README file that came with the widgets plugin. The answer was right there. All I had to do was insert the following into my functions.php file…

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

    …and all is well.

    Thanks anyway!

Viewing 1 replies (of 1 total)
  • The topic ‘php code to list titles?’ is closed to new replies.