WordPress 插件开发 增加自定义页面类型及前端显示页面 Add Custom page template with WordPress plugin

前篇我们讲到WordPress 插件开发 增加自定义页面类型及前端显示页面,下面我们记录一下简单的方法来达到同样的效果:

add_filter( 'page_template', 'jpage_template' );  function jpage_template( $page_template ){        if ( get_page_template_slug() == 'template-configurator.php' ) {          $page_template = dirname( __FILE__ ) . '/template-configurator.php';      }      return $page_template;  }    /**   * Add "Custom" template to page attirbute template section.   */  add_filter( 'theme_page_templates', 'jadd_template_to_select', 10, 4 );  function jadd_template_to_select( $post_templates, $wp_theme, $post, $post_type ) {        // Add custom template named template-custom.php to select dropdown       $post_templates['template-configurator.php'] = __('Configurator');        return $post_templates;  }

腾讯云限时秒杀【点击购买】

搬瓦工,CN2高速线路,1GB带宽,电信联通优化KVM,延迟低,速度快,建站稳定,搬瓦工BandwagonHost VPS优惠码BWH26FXH3HIQ,支持<支付宝> 【点击购买】!

Vultr$3.5日本节点,512M内存/500G流量/1G带宽,电信联通优化,延迟低,速度快【点击购买】!

阿里云香港、新加坡VPS/1核/1G/25G SSD/1T流量/30M带宽/年付¥288【点击购买】

WordPress 插件开发 增加自定义页面类型及前端显示页面 Add Custom page template with WordPress plugin

`微信`扫码 加好友

链接到文章: https://gkxyz.com/wordpress-chajiankaifa-zengjiazidingyiyemianleixingjiqianduanxianshiyemian-add-custom-page-template-wit.html

推荐站点

评论已关闭