八、制作侧边栏sidebar.php

get_sidebar()函数是可以加参数的。
比如:

这个代码加载sidebar-1.php,有的人希望网站上的首页、内页、分类页等各个页面的侧边栏不一样,这样就需要有多个侧边栏,这时候就得给这个函数加参数了。

编辑sidebar.php文件,将里面的代码删除,因为那些都是静态的,我们需要从后台设置小工具,所以删除了,改成:

class="grid_4">

if(!function_exists('dynamic_sidebar')

||!dynamic_sidebar('First_sidebar')):?>

分类目录

endif;?>

if(!function_exists('dynamic_sidebar')

||!dynamic_sidebar('Second_sidebar')):?>

最新文章

    $posts=get_posts('numberposts=6&orderby=post_date');

    foreach($postsas$post){

    setup_postdata($post);

    echo'

  • "'.get_permalink().'">'.get_the_title().'
  • ';

    }

    $post=$posts[0];

    ?>

endif;?>

if(!function_exists('dynamic_sidebar')

||!dynamic_sidebar('Third_sidebar')):?>

标签云

endif;?>

if(!function_exists('dynamic_sidebar')

||!dynamic_sidebar('Fourth_sidebar')):?>

文章存档

endif;?>

class="hrgrid_12clearfix"