最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Custom Page out of Wp Theme

programmeradmin1浏览0评论

i have this website running in WP and I had to create a feature to generate pages automatically and I did it through a separate WP backend, which creates the .php pages within the root of the site.

When I call domain/slug-of-page.php everything is ok.

But when I call the page without the extension (.php) the WP understands that it is an invalid url (404 error) because there is no page in the WP with that name.

I tried to insert the page created in the wp_posts table but when calling the page it loads the WP theme ... I don't want it to load the theme.

Is there a way to make the url friendly (without the extension) and not handled by the WP handler?

Thanks for every help.

i have this website running in WP and I had to create a feature to generate pages automatically and I did it through a separate WP backend, which creates the .php pages within the root of the site.

When I call domain/slug-of-page.php everything is ok.

But when I call the page without the extension (.php) the WP understands that it is an invalid url (404 error) because there is no page in the WP with that name.

I tried to insert the page created in the wp_posts table but when calling the page it loads the WP theme ... I don't want it to load the theme.

Is there a way to make the url friendly (without the extension) and not handled by the WP handler?

Thanks for every help.

Share Improve this question edited Nov 14, 2020 at 20:52 Tom J Nowell 61k7 gold badges79 silver badges148 bronze badges asked Nov 14, 2020 at 20:17 Renê LimaRenê Lima 31 bronze badge 5
  • 1 What is this separate WP backend that creates PHP files in the root of the WordPress site? Standard WordPress has no functionality to provide that. Normally you would create a page then assign it a page template which is a file in the theme, or have a template with a specific filename in the theme. Creating files in the main web root is unheard of in 99.99999% of WordPress installs, and considered bad practice – Tom J Nowell Commented Nov 14, 2020 at 20:54
  • Hi Tom, thanks for reply. This backend I created in php, absolutely custom code, and it runs inside the root folder of the site, in the same folder as wp-admin, wp-contents ... There is a template.php file, and every time, using the backend, we create a page, what happens is a copy of the template.php, renaming it to the page-name.php – Renê Lima Commented Nov 14, 2020 at 20:58
  • What I need is that I can use domain/custom-page without the WP looking for a page, how to escape this rule. – Renê Lima Commented Nov 14, 2020 at 21:12
  • 1 I think what you need to do that is Nginx rules, not WP changes, either that or you route the requests through WordPress and add a handler inside WP that routes things to custom code. Either way what you're literally asking for isn't possible because that's not how it works, but the result you desire is possible, it just requires Nginx rules to whitelist all the possible files. – Tom J Nowell Commented Nov 14, 2020 at 22:52
  • Thanks man, i will study about Nginx rules and try do it. – Renê Lima Commented Nov 14, 2020 at 23:38
Add a comment  | 

1 Answer 1

Reset to default 0

try this, wordpress has custom page templates.

Creating Custom Page Templates for Global Use

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论