Custom Sidebar - How to Add new Widget / Plugin (recent comments)

Posted on 2011-10-16
Last Modified: 2012-05-12
Hello, my site is

on the sidebar, I would like to get rid of Popular Articles and replace it with a new plugin i just installed called "Recent Comments with Avatars". Since I am unfamiliar with PHP, I am not sure what code to put in so I can do this...

Any help?

Thanks :)
<div class="mainright">

		  	<div id="sidebar">


<!-- Search Section -->			

			<div id="searchsection">

				<?php include (TEMPLATEPATH . '/searchform.php'); ?>

                <div class="clear"><!-- --></div>



			<?php 	/* Widgetized sidebar, if you have the plugin installed. */

					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>

<!-- End of Search Section -->		

<!-- Poll  -->	

<?php if (function_exists('vote_poll') && !in_pollarchive()): ?>				

	<div class="sidebarWrap" id="poll">


            <div class="sbContent">

            <?php get_poll();?>



    <?php endif; ?> 

<!-- End of Poll  -->

<!-- Your Ad Here -->

	<div class="sidebarWrap" id="sponsor2">

			<h2>Support our Sponsors</h2>

			<div class="sbContent">

<!-- Beginning of Project Wonderful ad code: -->

<!-- Ad box ID: 51333 -->

<script type="text/javascript">


var pw_d=document;

pw_d.projectwonderful_adbox_id = "51333";

pw_d.projectwonderful_adbox_type = "4";

pw_d.projectwonderful_foreground_color = "";

pw_d.projectwonderful_background_color = "";



<script type="text/javascript" src=""></script>

<!-- End of Project Wonderful ad code. -->





<!-- End of yOUR aD HERE   -->

<!-- Featured Stunna -->					

	<div class="sidebarWrap" id="featured">

			<h2>Stunna Babe of the Moment</h2>

			<div class="sbContent">

<script type="text/javascript" >NumberOfImagesToRotate = 12;FirstPart = '<img src="fansign/fan';LastPart = '.jpg" height="190" width="250">';function printImage() {var r = Math.ceil(Math.random() * NumberOfImagesToRotate);document.write(FirstPart + r + LastPart);}


<br><a href="">Be Seen! Submit your fan sign here</a>



<!-- End of Featured Stunna -->	

<!-- SZ Team  -->
<div class="sidebarWrap" id="team">

<div class="marTop">

<script type="text/javascript"><!--
google_ad_client = "ca-pub-7308943566145520";
/* bigger sidebar ad */
google_ad_slot = "4824911313";
google_ad_width = 250;
google_ad_height = 250;
<script type="text/javascript"


<!-- End of SZ Team  -->

<!-- Popular Post -->

	<div class="sidebarWrap" id="popPost">

			<h2>Popular Articles | Hot Topics</h2>

			<div class="sbContent">


			<? //popularPosts(5);
				 $popular = new WP_Query('orderby=comment_count&posts_per_page=10');
					 while ($popular->have_posts()) : $popular->the_post();
					 <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
					 <!--<span><?php //comments_popup_link('0 Comment', '1 Comment', '% Comments', 'comments-link', ''); ?></span>-->
					<?php endwhile;




<!-- End of Popular Post   -->

<!-- Support -->

<div class="sidebarWrap" id="support">


<div class="sbContent">

<form action="" method="post">

<input type="hidden" name="cmd" value="_s-xclick">

<input type="hidden" name="hosted_button_id" value="7051702"><input type="image" src="<?php bloginfo('template_directory'); ?>/images/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"></form>

<p>You can help keep this <a href="">free webzine </a> online.</p>        


<!-- End of Support   -->

<!-- Cool Sites  -->

<div class="sidebarWrap" id="coolSite">
<h2>Our Friends</h2>
<div class="sbContent">
<ul class="leftCol divider">

<li><a href="" rel="nofollow" class="menulink">Page Graphics</a></li>

<li><a href="" rel="nofollow" class="menulink2">Make You Laugh</a></li>
<ul class="leftCol">

<li><a href="" rel="nofollow" class="menulink">Konvict and Tip-Z</a> </li>

<li><a href="" rel="nofollow" class="menulink">MySpace Hoz</a></li>

<div class="clear"><!-- --></div>
<!-- End of Cool Sites  -->
<?php endif; ?>

</div> <!-- End side bar -->

<div class="clear"><!-- --></div>

Open in new window

Question by:VenusBreeze
    LVL 42

    Expert Comment

    by:David S.
    LVL 23

    Accepted Solution

    Just add this to your functions.php file:
     'before_widget' => '<ul><li>',
     'after_widget' => "</li></ul>",
     'before_title' => '<h2 class="widgettitle">',
     'after_title' => "</h2>"

    Open in new window

    Then add this to your sidebar.php file:
      <div class="bottom-sidebar">
        <?php if ( function_exists ( dynamic_sidebar(4) ) ) : ?>
        <?php dynamic_sidebar (4); ?>
        <?php endif; ?>

    Open in new window

    You'll now have a place to drag the widget in your Appearance>Widgets panel.

    I'm not sure if you've noticed, or maybe don't care but your sidebar has at least two javascript functions in it. This is a problem waiting to happen. If you start having issues with plugins not working or any other number of issues, that's where I'd start troubleshooting. In WordPress all Javascript should be registered either in the head, or after the wp_footer hook. Best practice is to use the functions.php file to register the scripts. If the sidebar is that bad, the rest of the theme is probably a hack also.
    Good Luck.
    LVL 2

    Assisted Solution

    by:Ryan Bayne
    He is right on the Javascript note for sure.

    I add a lot of Javascript too my own plugins admin pages but I only load the Javascript when those pages are being viewed. It limits any conflict and it makes for fast development but it is still not 100% safe so I will eventually move it all to be adding in header or footer.

    Don't worry about it too much if your not planning on adding many plugins you'll probably be fine but Wordpress can protect you from conflict by doing what jeremyjared74 recommends.
    LVL 70

    Expert Comment

    by:Jason C. Levine
    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now