WordPress 在线问答插件:DW Question & Answer[基于官方 1.4.5 汉化]

痕风 2023年10月30日23:46:40
评论
225

DW Question & Answer 插件就不用多说了,相信能找到这儿来的都是已经了解它的强大功能。今天沃森网跟大家分享“WordPress 在线问答插件:DW Question & Answer[基于官方 1.4.5 汉化]”,觉得不错请点赞分享。

插件介绍

DW Question & Answer 可以为你的 WordPress 网站添加一个功能全面的 完全免费在线问答中心。用户可以提交问题,搜索和按状态过滤的问题,得到别人的回答。用户可以评论和回复问题或答案,可以投票,可以设置问题的最佳回答。

主要功能

  • 提交问题
  • 通过分类或标签排序问题
  • 提交回答
  • 选择问题的最佳答案
  • 对问题和答案进行评论、投票
  • 可定制的邮件通知
  • 可以设置不同用户角色的操作权限
  • 快速过滤问题
  • 通过状态管理问题,比如待回答、已回答、已关闭等等
  • 通过关键字即时搜索

另外,可在此设置定制邮件及设置相关的权限。若访问问答页面出现 404,到 wp 后台>设置>固定链接 ,重新保存一遍设置即可;

最后将新建的“问答中心”页面添加到导航菜单上即可。
WordPress 在线问答插件:DW Question & Answer[基于官方 1.4.5 汉化]

技巧分享

设定固定链接结构为数字 id.html 结构

如果觉得自带的 url 结构不够简洁,要想加这个问答的固定链接结构设置为 id.html 结构,只需将下面的代码添加到当前主题的 functions.php中即可 :

/**
 * 自定义问答页面的固定链接结构为 id.html
 */
add_filter('post_type_link', 'lxtx_custom_qa_link', 1, 3);
function lxtx_custom_qa_link( $link, $post = 0 ){
    if ( $post->post_type == 'dwqa-question' ){
        return home_url( 'question/' . $post->ID .'.html' );
    } else {
        return $link;
    }
}
add_action( 'init', 'lxtx_custom_qa_rewrites_init' );
function lxtx_custom_qa_rewrites_init(){
    add_rewrite_rule(
        'question/([0-9]+)?.html$',
        'index.php?post_type=dwqa-question&p=$matches[1]',
        'top' );
}

添加后,如果访问问答页面出现 404 错误,请访问 WP 后台 – 设置 – 固定链接,保存一遍这里的设置即可。如果还不行,很可能是你的主机不支持伪静态,请联系你的主机商。

插件下载

在后台搜索 DW Question & Answer 即可在线安装,或者在这里下载。

DW Question & Answer 下载:

链接: https://pan.baidu.com/s/1nwTpFap 密码: dst9

注 1:最好不要在自己的主站上安装使用该插件,可能会影响主站速度,建议在子目录单独安装一个 WP 程序用于问答插件,比如这种格式:http://wosn.net/faq/

然后进入 WP 后台 → 设置 → 阅读,在阅读设置页面,首页显示 →勾选“ 一个静态页面”并选择“问答中心”页面,这样打开网站首页就会直接显示问答中心页面了。

 定制个性页面

通过修改模板可制作特有的个性页面。下面就提供几个制作特色问答页面所需要的列表代码。(网上很难找到的,看着有用的话就赶紧收藏哦!

1. 最新问题列表

<?php
/**
* 调用最新问题列表 By ILXTX.COM
* https://www.ilxtx.com/dw-question-answer.html
*/
$instance = wp_parse_args( $instance, array(
    'title' => __('Latest Questions','dwqa'),
    'number' => 6  //调用的多少条
) );
$args = array(
    'posts_per_page' => $instance['number'],
    'order' => 'DESC',
    'orderby' => 'post_date',
    'post_type' => 'dwqa-question',
    'suppress_filters' => false
);
$questions = new WP_Query( $args );
while( $questions->have_posts() ) {
    $questions->the_post();
?>
    <li><a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_title();?></a></li>
<?php } wp_reset_postdata(); ?>

2. 随机问题列表

<?php
/**
* 调用随机问题列表 By ILXTX.COM
* https://www.ilxtx.com/dw-question-answer.html
*/
$instance = wp_parse_args( $instance, array(
    'title' => __('Random Questions','dwqa'),
    'number' => 6  //调用的多少条
) );
$args = array(
    'posts_per_page' => $instance['number'],
    'order' => 'DESC',
    'orderby' => 'rand',
    'post_type' => 'dwqa-question',
    'suppress_filters' => false
);
$questions = new WP_Query( $args );
while( $questions->have_posts() ) {
    $questions->the_post();
?>
    <li><a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_title();?></a></li>
<?php } wp_reset_postdata(); ?>

3. 热门问题列表

<?php
/**
* 调用热门问题列表 By ILXTX.COM
* https://www.ilxtx.com/dw-question-answer.html
*/
$instance = wp_parse_args( $instance, array(
    'title' => __('Popular Questions','dwqa'),
    'number' => 6  //调用的多少条
) );
$args = array(
    'posts_per_page' => $instance['number'],
    'order' => 'DESC',
    'orderby' => 'meta_value_num',
    'meta_key' => '_dwqa_views',
    'post_type' => 'dwqa-question',
    'suppress_filters' => false
);
$questions = new WP_Query( $args );
while( $questions->have_posts() ) {
    $questions->the_post();
?>
    <li><a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_title();?></a></li>
<?php } wp_reset_postdata(); ?>
继续阅读
weinxin
痕风的起点
专注于互联网资讯、中央空调、Windows、wordpress、建站技术、软件应用等相关网络资源的分享。
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: