php 注册新端点以在“我的帐户”页面中使用,然后获取模板文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 注册新端点以在“我的帐户”页面中使用,然后获取模板文件相关的知识,希望对你有一定的参考价值。

/**
  * Register new endpoints to use inside My Account page.
  */

 add_action( 'init', 'my_account_new_endpoints' );

 function my_account_new_endpoints() {
 	add_rewrite_endpoint( 'directory', EP_ROOT | EP_PAGES );
 	add_rewrite_endpoint( 'postgenerator', EP_ROOT | EP_PAGES ); 	
 }

/**
  * Get new endpoint content
  */
 
  // Directory
 add_action( 'woocommerce_account_directory_endpoint', 'directory_endpoint_content' );
 function directory_endpoint_content() {
     get_template_part('myaccount-directory');
 }
 
  // Post Generator
 add_action( 'woocommerce_account_postgenerator_endpoint', 'postgenerator_endpoint_content' );
 function postgenerator_endpoint_content() {
     get_template_part('myaccount-postgenerator');
 }

以上是关于php 注册新端点以在“我的帐户”页面中使用,然后获取模板文件的主要内容,如果未能解决你的问题,请参考以下文章