wordpress 系列之 header 导航

使用Menu Maker 进行导航设计的批量处理,使用默认的links表来保存导航

首先安装插件:

http://wordpress.org/extend/plugins/menumaker/ 或者 http://downloads.wordpress.org/plugin/menumaker.0.6.zip

说明文档:

  1. Upload the menumaker directory to the /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Go to Options > Menu Maker and change options and add menus
  4. Place <?php id_menu_maker(); ?> in your templates

上面是原始的安装方式。

此时我们来修改文件。

1,打开文件menumaker.php,添加如下的函数。

//use  the default link table to show links.
function sql_menu_maker() {
    global $wpdb;//调用系统的数据库配置
    $output = '';
    $links = $wpdb->get_results ( "Select link_name,link_url from `$wpdb->links" );//系统的数据库查询结果集函数
    $output .= "<ul>\n";
    foreach ( $links as $link ) {
        $output .= '<li><a href="' . $link->link_url . '" title="' . $link->link_name . '">' . $link->link_name . '</a></li>';
    } //输出output
    $output .= "\n</ul>";
    echo $output;
}

2,打开需要存放导航的template:

<div id="menu">    
  <?php sql_menu_maker(); ?>
  <div class="clear-both"></div>
</div>

这样以后添加的links 就可以在页面上作为导航显示了,同时呢,也可以自定义导航的css,方便操作。

 

posted @ 2013-01-09 16:34  awinlei  阅读(343)  评论(0编辑  收藏  举报