原文地址:http://liuyanzhao.com/1994.html
博主今天受一群友委托,帮他的dux主题(好像是1.7)添加推荐和联系模块,同时,他也给了我一个链接(http://www.andykwok.cc/wordpress-dux-tuijian-lianxi.html),参考。可能是版本不同的原因,该教程已经失效。下面博主将最新方法公诸于众,同时与之前的做一个对比。
打开主题目录下的options.php文件,搜索“选择分类设置为网站公告”,在其下一行添加以下代码:
$options[] = array("name" => __("首页公告", "haoui"), "type" => "heading");
$options[] = array("id" => "site_notice_s", "std" => false, "desc" => __("显示公告模块", "haoui"), "type" => "checkbox");
$options[] = array("name" => __("显示标题", "haoui"), "id" => "site_notice_title", "desc" => "建议4字内,默认:网站公告", "std" => "网站公告", "type" => "text");
$options[] = array("name" => __("选择分类设置为网站公告", "haoui"), "id" => "site_notice_cat", "options" => $options_categories, "type" => "select");
$options[] = array('name' => __('强烈推荐', 'haoui'), 'type' => 'heading');
$options[] = array('id' => 'site_tuijian_s', 'std' => false, 'desc' => __('显示推荐模块', 'haoui'), 'type' => 'checkbox');
$options[] = array('name' => __('显示标题', 'haoui'), 'id' => 'site_tuijian_title', 'desc' => '建议4字内,默认:强烈推荐', 'std' => '强烈推荐', 'type' => 'text');
$options[] = array('name' => __('显示文本', 'haoui'), 'id' => 'site_tuijian_text', 'desc' => '可自定义,默认:andykwok.cc强烈推荐:AndyKwok.cc分享所分享的', 'std' => 'andykwok.cc强烈推荐:andykwok.cc
AndyKwok.cc最好的Blog', 'type' => 'textarea');
$options[] = array('name' => __('按钮 ', 'haoui') , 'id' => 'site_tuijian_button' , 'desc' => '按钮文字', 'std' => '点击查看', 'type' => 'text');
$options[] = array('id' => 'site_tuijian_url' , 'desc' => __('按钮链接', 'haoui'), 'std' => 'http://www.andykwok.cc/', 'type' => 'text');
$options[] = array('id' => 'site_tuijian_blank' , 'std' => false, 'desc' => __('新窗口打开', 'haoui'), 'type' => 'checkbox');
$options[] = array('name' => __('联系我们', 'haoui'), 'type' => 'heading');
$options[] = array('id' => 'site_aboutus_s', 'std' => false, 'desc' => __('显示联系我们模块', 'haoui'), 'type' => 'checkbox');
$options[] = array('name' => __('显示标题', 'haoui'), 'id' => 'site_aboutus_title', 'desc' => '可自定义,默认:联系我们', 'std' => '联系我们', 'type' => 'text');
$options[] = array('name' => __('显示文本', 'haoui'), 'id' => 'site_aboutus_text', 'desc' => '可自定义,默认:如有疑问,请留言或邮件咨询
[email protected]
', 'std' => '如有疑问,请留言或邮件咨询
[email protected]
', 'type' => 'textarea');
找到主题文件夹下的modules文件夹下的mo_notice.php,如图,用编辑器打开
找到
_moloader("mo_get_user_page", false);
在它的下面加以下两行代码
$s_tuijian = _hui("site_tuijian_s");
$s_aboutus = _hui("site_aboutus_s");
找到
再它下面添加下面代码,可以看一下我的图。
if ($s_tuijian) {echo ";echo $s_tuijian && !$s_notice ? " class=\"active\"" : "";echo ">强烈推荐 ";} ?>
if ($s_aboutus) {echo ";echo $s_aboutus && !$s_notice ? " class=\"active\"" : "";echo ">联系我们 ";} ?>
找到代码最下面的
ul>
div>
}
在它前面添加以下代码
$s_tuijian && _hui("site_tuijian_s"))
{
echo "\t\t\t\t\"item item-04";
echo $s_tuijian && !$s_notice ? " active" : "";
echo "\">\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t";
echo _hui("site_tuijian_text") ? _hui("site_tuijian_text") : "强烈推荐";
?>
\t
\t\t\t\t\r\n\t\t\t\t \r\n\t\t\t";
}
?>
s_aboutus && _hui("site_aboutus_s"))
{
echo "\t\t\t\t\"item item-04";
echo $s_aboutus && !$s_notice ? " active" : "";
echo "\">\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t";
echo _hui("site_aboutus_text") ? _hui("site_aboutus_text") : "联系我们";
echo "\t\t\t\t\t
\r\n\t\t\t\t \r\n\t\t\t";
}
?>
如图(博主为了方便截图,把编辑器代码折叠了)