Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

Thanks

share|improve this question
add comment

2 Answers

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>
<ul>
<?php
    $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> ';
    }
?>
</ul>

(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
add comment

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
add comment

Your Answer

 
discard

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.