After developed a couple of thematic child themes I think its time to collect a few snippets (for function.php) for future use. Hope you find them useful too.
Action hook and filter are very powerful in building thematic child themes. Before you go ahead and copy past things please make sure you have some level of understanding on conditional tag, thematic action hook and filter.
- You may be interested in the following related posts:
- how I made a wordpress Child theme with thematic (1)
- how I made a wordpress child theme with thematic (2)
- Free WordPress theme Audry release
NOTE: I will keep updating this post, and you are welcome to give suggestion.
Add Javascript at head section
This example shows how to add javascripts and link files in your child theme directory if it is home page.
function my_in_head(){
if(is_home()){?>
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/jeasing.js"></script>
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/cycle.js"></script> <script type="text/javascript">
<script type="text/javascript">
//your scripts
</script><?php }}
add_action('wp_head', 'my_in_head');Add a search in header
Many sites demand the search at header section
function add_search(){ include (TEMPLATEPATH . '/searchform.php'); } add_action('thematic_header','add_search');
Have an empty post footer
Sometimes it is good to leave the post footer empty. You can use this filter to empty any other sections as you like
add_filter('thematic_postfooter','my_postfooter'); function my_postfooter() { //nothing } add_filter('thematic_postfooter','my_postfooter');
Add custom section for certain pages
This snippet adds a div (deco) below the site header
function add_deco(){ if (is_page()||is_single()){echo '<div id="deco"></div>';}} add_action('thematic_belowheader','add_deco');