最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Is there an error in my code?

programmeradmin2浏览0评论

The code I'm using works, but I'm a newbie, does this code have any errors, wrong syntax, or redundant code?

define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );



add_filter( 'template_include', 'amp_page_template', 99 );

function amp_page_template( $template ) {

    if( get_query_var( AMP_QUERY_VAR, false ) !== false ) {


        if ( is_single() ) {

            $template = get_template_directory() .  '/amp-single.php';

        } 

    }

    return $template;
}
// Whitelist query vars
add_filter( "query_vars", "my_query_vars" );
function my_query_vars( $vars ) {
    $vars[] = AMP_QUERY_VAR;
    return $vars;
}

function custom_rewrite_rule() {
    add_rewrite_rule('^'. AMP_QUERY_VAR .'/([^/]*)/?','index.php?'. 
AMP_QUERY_VAR .'=1&name=$matches[1]','top');
}
add_action('init', 'custom_rewrite_rule', 10, 0 );

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论