WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Insert break in dynamic sidebar (7 posts)

  1. chase453
    Member
    Posted 6 years ago #

    I know this should be an easy question, but I've been searching for over an hour and can't seem to find a solution to this simple issue. How can I insert a break or separator between widgets in a dynamic sidebar? For example, in my side, I have a dynamic sidebar (col2) and a static sidebar (col3). I can edit the static sidebar with whatever html I want to include breaks, but I can't find where I can insert a break into the dynamic sidebar anywhere.

    If you look at my site, http://www.chasecheviron.com, you'll see the 3rd column is how I want it..with a line break in between the "search" and "recent photos" headings, but the 2nd column has "archives" and the calendar smashed together w/ no break between them.

    Ideas??

  2. Maxaud
    Member
    Posted 6 years ago #

    Give the following page a read:
    http://automattic.com/code/widgets/themes/

    What you'll want to do is edit your functions.php file to say something like this:

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'before_widget' => '',
            'after_widget' => '<br />',
            'before_title' => '',
            'after_title' => '',
        ));
    ?>
  3. chase453
    Member
    Posted 6 years ago #

    Excellent!! Thank you for the help -- I ended up using the above code (minus this part below):

    'before_title' => '',
    'after_title' =>'',

    I found that if I included this part, the headings appeared incorrectly. So, just got rid of that, and it works like a charm. Thanks again.

  4. Maxaud
    Member
    Posted 6 years ago #

    Yep! Glad I could be of help!

  5. dj-primat
    Member
    Posted 6 years ago #

    Can you tell me please how can i insert php code into
    'before_title' => 'here i need php',

  6. jvining
    Member
    Posted 6 years ago #

    Here is the code that is in my functions.php - when I try to edit it to add the breaks it trashes the entire WP install and I have to revert to a fresh functions.php file.

    Does anyone have any idea how to help me get some breaks between these damn widgets? This is the code at the top of functions.php right now... what should it be changed to?

    `<?php
    if ( function_exists('register_sidebar') )
    register_sidebars(2);'

  7. Maxaud
    Member
    Posted 6 years ago #

    this might work:

    <?php
    if ( function_exists('register_sidebar') )
    {
        register_sidebar
        (   array
            (
              'name' => 'name-one',
              'before_widget' => '',
              'after_widget' => '<br />',
              'before_title' => '',
              'after_title' => '',
            )
        );
        register_sidebar
        (   array
            (
              'name' => 'name-two',
              'before_widget' => '',
              'after_widget' => '<br />',
              'before_title' => '',
              'after_title' => '',
            )
        );
    }
    ?>

    you will want to replace the names (name-one/name-two) with whatever you named your sidebars in the theme.

Topic Closed

This topic has been closed to new replies.

About this Topic