WordPress.org

Ready to get started?Download WordPress

Forums

customizing sidebar widgets - how?! (7 posts)

  1. Qbs
    Member
    Posted 5 years ago #

    hi
    I want my sidebar to display 4 of the most recent posts and comments so I added the two built-in widgets but the problem is that the mark-up isn't even close to what I need

    using my functions.php I've added

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'before_widget' => '',
            'after_widget' => '',
            'before_title' => '<h1 class="cyan">',
            'after_title' => '</h1>',
        ));
    ?>

    but that's only about 10% percent of the markup that I need...
    the widgets return the following HTML code

    <h1 class="cyan">Najnowsze komentarze</h1>
    <ul id="recentcomments">
    <li class="recentcomments">Qbs o <a href="http://fortywinks.pl/kkk/?p=16#comment-7">Lorem ipsum dolor sit amet</a></li>
    <li class="recentcomments">kolejny test o <a href="http://fortywinks.pl/kkk/?p=1#comment-6">Witaj, świecie!</a></li>
    <li class="recentcomments">admin o <a href="http://fortywinks.pl/kkk/?p=1#comment-5">Witaj, świecie!</a></li>
    <li class="recentcomments">test o <a href="http://fortywinks.pl/kkk/?p=1#comment-4">Witaj, świecie!</a></li>
    </ul>

    and I'd like to have such a markup:

    <h1 class="cyan">Najnowsze komentarze</h1>
                    <div class="box">
                    	<ul>
                        	<li class="comments"><a href="#">Lorem ipsum dolor sit amet.</a></li>
                            <li class="comments"><a href="#">Lorem ipsum dolor sit amet.</a></li>
                            <li class="comments"><a href="#">Lorem ipsum dolor sit amet.</a></li>
                            <li class="comments"><a href="#">Lorem ipsum dolor sit amet.</a></li>
                        </ul>
                    </div>
                <div class="sideLine">&nbsp;</div>

    those <li class=""> are essential because I need a different class for the comments and another for posts

    please help!
    thanks

  2. Qbs
    Member
    Posted 5 years ago #

    I've tried this solution from - http://codex.wordpress.org/Widgetizing_Themes

    function widget_mytheme_search() {
    ?>
        << PASTE YOUR SEARCH FORM HERE >>
    <?php
    }
    if ( function_exists('register_sidebar_widget') )
        register_sidebar_widget(__('Search'), 'widget_mytheme_search');

    but I can't get it to work even with this basic example :/

  3. Qbs
    Member
    Posted 5 years ago #

    bump...

  4. Qbs
    Member
    Posted 5 years ago #

    bump...

  5. needle189
    Member
    Posted 5 years ago #

    `<?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'before_widget' => '',
    'after_widget' => '</div>',
    'before_title' => '<h1 class="cyan">',
    'after_title' => '</h1> <div class="box">',
    ));
    ?>

    try this hope it works

  6. Qbs
    Member
    Posted 5 years ago #

    needle189: thanks but that's not all because still I need to add classes to

  7. elements
    <li class="comments"> for the recent comments
    `<li class="posts"> for the recent posts
  • needle189
    Member
    Posted 5 years ago #

    hey if you want to use the widget system then I am afraid it's not possible. You have to create your own separate code block, I am afraid, if you want to have custom styling for recent comments and recent posts section

    regards

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags