0

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

2 Answers 2

1

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.

1

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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