admin管理员组文章数量:1122832
I want to create a URL to an activation page in Wordpress. But I don't want to create a page for it with a shortcode. So it must be a dynamic page.
I'm currently trying to see if I can do it with a REST API. And so far activation has been successful. I have created a REST route and I get the activation code (which is part of the link) as a variable. But I cannot show a page with a message that the activation was successful, not within the chosen theme. All HTML I send to the browser is displayed on a black page, without the theme.
I'm starting to wonder if I'm on the right path, or is the REST API intended for something else?
This is what I have so far:
$this->loader->add_action( 'rest_api_init', $plugin_public, 'course_add_enpoint');
public function course_add_enpoint(){
register_rest_route('course_manager/v1', 'activation/(?P<id>[A-Za-z0-9]+(_[A-Za-z0-9]+)+)', array(
'methods' => 'GET',
'callback' => array ($this, 'course_activation'),
));
}
public function course_activation( $data ){
returns HTML code
}
So far the activation works, but the page with HTML code is not the same as a page with the layout of the theme. Can someone point me in the right direction, am I working with the REST API or should I look elsewhere?
I want to create a URL to an activation page in Wordpress. But I don't want to create a page for it with a shortcode. So it must be a dynamic page.
I'm currently trying to see if I can do it with a REST API. And so far activation has been successful. I have created a REST route and I get the activation code (which is part of the link) as a variable. But I cannot show a page with a message that the activation was successful, not within the chosen theme. All HTML I send to the browser is displayed on a black page, without the theme.
I'm starting to wonder if I'm on the right path, or is the REST API intended for something else?
This is what I have so far:
$this->loader->add_action( 'rest_api_init', $plugin_public, 'course_add_enpoint');
public function course_add_enpoint(){
register_rest_route('course_manager/v1', 'activation/(?P<id>[A-Za-z0-9]+(_[A-Za-z0-9]+)+)', array(
'methods' => 'GET',
'callback' => array ($this, 'course_activation'),
));
}
public function course_activation( $data ){
returns HTML code
}
So far the activation works, but the page with HTML code is not the same as a page with the layout of the theme. Can someone point me in the right direction, am I working with the REST API or should I look elsewhere?
Share Improve this question edited Jun 2, 2024 at 13:04 Buttered_Toast 2,8191 gold badge8 silver badges21 bronze badges asked Jun 1, 2024 at 14:18 Rene van DamRene van Dam 11 bronze badge1 Answer
Reset to default 0OK, I found a page how to create a fake page and it's exactly what I needed: https://geek.hellyer.kiwi/2018/creating-fake-wordpress-pages/
本文标签: rest apiDynamic activation page in Wordpress
版权声明:本文标题:rest api - Dynamic activation page in Wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736305125a1932479.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论