• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 526
  • Last Modified:

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

Hello, my site is http://tiny.cc/a4guz 

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="http://www.projectwonderful.com/ad_display.js"></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="http://www.stunnazine.com/fan-sign-submission.html">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="https://www.paypal.com/cgi-bin/webscr" 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="http://www.stunnazine.com/about.html">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="http://www.hairflip.net" rel="nofollow" class="menulink">Page Graphics</a></li>

<li><a href="http://wemakeyoulaugh.blogspot.com/" rel="nofollow" class="menulink2">Make You Laugh</a></li>
<ul class="leftCol">

<li><a href="http://www.steelcitymovement.webs.com" rel="nofollow" class="menulink">Konvict and Tip-Z</a> </li>

<li><a href="http://www.myspacehoz.com" 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

2 Solutions
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.
Ryan BayneWordPress DeveloperCommented:
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.
Jason C. LevineNo oneCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now