Wednesday, August 18, 2010

Create your customize sidebar in the blog frontend

This code will customize your sidebar in your blog theme you can get it in the sidebar.php


<div id="primary" class="widget-area" role="complementary">

<ul class="xoxo">

<?php/* When we call the dynamic_sidebar() function, it'll spit out
* the widgets for that widget area. If it instead returns false,
* then the sidebar simply doesn't exist, so we'll hard-code in
* some default sidebar stuff just in case.*/
//if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : ?>

<!--<li id="search" class="widget-container widget_search">

<?php //get_search_form(); ?>


</li>
-->


<li id="archives" class="widget-container">


<h3 class="widget-title">
<?php _e( 'Recent Posts', 'twentyten' ); ?>
</h3>


<ul>


<?php wp_get_archives('title_li=&type=postbypost&limit=100'); ?>


</ul>


</li>



<li id="archives" class="widget-container">


<h3 class="widget-title">
<?php _e( 'Recent Comments', 'twentyten' ); ?>
</h3>


<ul>


<?php

foreach((get_comments(array('number' =>
30, 'status' =>
'approve'))) as $recent_comments){ ?>


<li>


<a href="<?php echo $recent_comments->
comment_author_url; ?>
">
<?php echo $recent_comments->
comment_author . ' '; ?>
</a>
On <?php $id = $recent_comments->
comment_post_ID; ?>
<a href="<?php echo get_post( $id, $output )->
guid; ?>
">
<?php echo get_post( $id, $output )->
post_title; ?>
</a>


</li>


<?php } ?>


</ul>


</li>



<li id="archives" class="widget-container">


<h3 class="widget-title">
<?php _e( 'Archives', 'twentyten' ); ?>
</h3>


<ul>


<?php wp_get_archives( 'type=monthly' ); ?>


</ul>


</li>



<!--<li id="archives" class="widget-container">


<h3 class="widget-title">
<?php _e( 'Categories', 'twentyten' ); ?>
</h3>


<ul>


<?php

foreach((get_the_category()) as $category) { ?>


<li>


<a href="<?php echo get_category_link( $category->
cat_ID ); ?>
">
<?php echo $category->
cat_name . ' '; ?>
</a>


</li>


<?php } ?>


</ul>


</li>
-->

<li id="meta" class="widget-container">


<h3 class="widget-title">
<?php _e( 'Meta', 'twentyten' ); ?>
</h3>


<ul>


<?php wp_register(); ?>


<li>
<?php wp_loginout(); ?>
</li>


<?php wp_meta(); ?>


</ul>


</li>


<?php //endif; // end primary widget area ?>


</ul>


</div>
<!-- #primary .widget-area -->


<?php

// A second sidebar for widgets, just because.

//if ( is_active_sidebar( 'secondary-widget-area' ) ) : ?>


<!--<div id="secondary" class="widget-area" role="complementary">


<ul class="xoxo">


<?php// dynamic_sidebar( 'secondary-widget-area' ); ?>


</ul>


</div>
-->

<!-- #secondary .widget-area -->
<?php //endif; ?>


No comments:

Post a Comment