当前位置:首页-所有文章-未分类-正文

hb

定义问答页面的固定

/**
 * 自定义问答页面的固定链接结构为 id.html
 * https://www.ilxtx.com/dw-question-answer.html
 */
add_filter('post_type_link', 'custom_qa_link', 1, 3);
function 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', 'custom_qa_rewrites_init' );
function custom_qa_rewrites_init(){
    add_rewrite_rule(
        'question/([0-9]+)?.html$',
        'index.php?post_type=dwqa-question&p=$matches[1]',
        'top' );
}

Warning: Attempt to read property "roles" on bool in /var/blog/wp-content/themes/slearn-pro/Module/View/Single.class.php on line 142
本文原创,作者:,其版权均为龙腾求知社所有。
如需转载,请注明出处:https://blog.longtengwx.com/407.html