WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am building a child theme based on Thematic.

Rather than use widgets, I would like to hard code my sidebar but I can't figure out how to do this.

Any help appreciated!


share|improve this question
up vote 1 down vote accepted

You can...

1. Enter your sidebar.php file and remove everything..
(better to just remove the code that calls the widigtized sidebar see examples)

example 1 (it might look like this):

<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('pages') ) : else : ?><?php endif; ?>

example 2 (it might also look like this):

<?php wp_nav_menu( array( 'theme_location' => 'primary-menu' ) ); ?>

Then you need to write your own code...
Every thing you might want to show in your sidebar.

Lets Say you want to show the latest post so.. you need to right the code for it:

<h2>Recent Posts</h2>
    $recent_posts = wp_get_recent_posts();
    foreach( $recent_posts as $recent ){
        echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.$recent["post_title"].'" >' .   $recent["post_title"].'</a> </li> ';

(source: http://codex.wordpress.org/Function_Reference/wp_get_recent_posts)

. This would retrieve a list of recent posts.
In this manner you can build parts of your sidebar in your sidebar.php file or which ever file you want to include inside your template as a sidebar file.

share|improve this answer

Create another PHP file with all your custom content (let us call it custom_sidebar.php ). Then include (or replace sidebar.php) on pages/templates the following line (where you want the content):

<?php get_template_part( 'custom_sidebar' ); ?>

You just remove the .php suffix when including it (like above).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.