url rewriting - Unable to access the query variables in the template

I added a custom endpoint 'product' in the pages.add_action( 'init', 'add_endpoints');fun

I added a custom endpoint 'product' in the pages.

add_action( 'init', 'add_endpoints');
function add_endpoints() {
   add_rewrite( 'product', EP_PAGES );
}

I added a shortcode called `'dashboard' shortcode in a page.

add_shortcode( 'ims-dashboard', 'dashboard' );
public function dashboard() {
   global $wp_query;

   return ims_get_template_html( 'admin-panel/admin-panel.php' );

}

When i access the page https://localhost/dashboard-2/product, it is rendered correctly.

But whenever I access the page https://localhost/dashboard-2/product/add, the

Oops! That page can’t be found.

is occurred.

I want to load the different page when the url is https://localhost/dashboard-2/product/add.

I added a custom endpoint 'product' in the pages.

add_action( 'init', 'add_endpoints');
function add_endpoints() {
   add_rewrite( 'product', EP_PAGES );
}

I added a shortcode called `'dashboard' shortcode in a page.

add_shortcode( 'ims-dashboard', 'dashboard' );
public function dashboard() {
   global $wp_query;

   return ims_get_template_html( 'admin-panel/admin-panel.php' );

}

When i access the page https://localhost/dashboard-2/product, it is rendered correctly.

But whenever I access the page https://localhost/dashboard-2/product/add, the

Oops! That page can’t be found.

is occurred.

I want to load the different page when the url is https://localhost/dashboard-2/product/add.

Share Improve this question asked Apr 4, 2019 at 6:19 Sagar Bahadur TamangSagar Bahadur Tamang 1331 silver badge10 bronze badges 6
  • 2 Do you have a post type of product on your site? If so, change the name of the endpoint - e.g. to product2 .. And there's a typo in the question - it's add_rewrite_endpoint(), not add_rewrite(). – Sally CJ Commented Apr 4, 2019 at 6:52
  • It seems I did. Thanks for point it out. – Sagar Bahadur Tamang Commented Apr 4, 2019 at 6:55
  • 1 So I suppose you've also flushed the rewrite rules? – Sally CJ Commented Apr 4, 2019 at 6:56
  • 1 Yes, I missed your comment edit. So make certain that the endpoint name does not clash with a post type slug - e.g. the product in your case. – Sally CJ Commented Apr 4, 2019 at 7:02
  • 1 Thanks for the help. I will keep in mind next time. – Sagar Bahadur Tamang Commented Apr 4, 2019 at 7:25
 |  Show 1 more comment

1 Answer 1

Reset to default 0

I have WooCommerce installed. It has registered the product post type which was conflicting with it.

I renamed to endpoint and it works.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745630601a4637086.html

相关推荐

  • url rewriting - Unable to access the query variables in the template

    I added a custom endpoint 'product' in the pages.add_action( 'init', 'add_endpoints');fun

    22天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信