admin管理员组文章数量:1025477
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 | Show 1 more comment1 Answer
Reset to default 0I have WooCommerce installed. It has registered the product post type which was conflicting with it.
I renamed to endpoint and it works.
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. toproduct2
.. And there's a typo in the question - it'sadd_rewrite_endpoint()
, notadd_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
1 Answer
Reset to default 0I have WooCommerce installed. It has registered the product post type which was conflicting with it.
I renamed to endpoint and it works.
本文标签: url rewritingUnable to access the query variables in the template
版权声明:本文标题:url rewriting - Unable to access the query variables in the template 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745630599a2160141.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
product
on your site? If so, change the name of the endpoint - e.g. toproduct2
.. And there's a typo in the question - it'sadd_rewrite_endpoint()
, notadd_rewrite()
. – Sally CJ Commented Apr 4, 2019 at 6:52product
in your case. – Sally CJ Commented Apr 4, 2019 at 7:02