简体   繁体   English

是否可以访问 wordpress 主题上的 php 脚本

[英]Is there access a php script on a wordpress theme

i have tried to load a flat panel write on PHP i put in a wordpress theme.我试图加载一个平板写在 PHP 上,我放入了一个 wordpress 主题。 for alone the script run great but i want run that on wordpress theme.仅凭脚本运行得很好,但我想在 wordpress 主题上运行它。

problem in them routing.他们的路由问题。 for example: site/wp-content/themes/admin/dashboard/ site/wp-content/themes/admin/dashboard/sprofile site/wp-content/themes/admin/dashboard/rprofile例如:site/wp-content/themes/admin/dashboard/site/wp-content/themes/admin/dashboard/sprofile site/wp-content/themes/admin/dashboard/rprofile

can not access above route.无法访问以上路线。

i think this solve with .htaccess file but don't know how !?我认为这可以用 .htaccess 文件解决,但不知道如何解决!? is there any way?!有什么办法吗?!

If you're using wordpress you may want to create a shortcode for your script but, in case you don't want to, you can also use .htaccess with the rewrite module to redirect a url and access your panel.如果您使用的是 wordpress,您可能想为您的脚本创建一个短代码,但如果您不想,您也可以使用 .htaccess 和 rewrite 模块来重定向 url 并访问您的面板。

Here are two examples that I hope will help you:举两个例子,希望对你有帮助:

.htaccess rewrite examples .htaccess 重写示例

Shortcode examples 简码示例

If I understood your situation correctly, you want to run a piece of PHP code which prints stuff inside the page as a feature in your WP theme.如果我正确理解您的情况,您希望运行一段 PHP 代码,该代码将页面内的内容打印为 WP 主题中的一项功能。 Not knowing the details, i can give you a couple of ideas:不知道细节,我可以给你几个想法:

  1. If you need to embed that in an existing page (or sa new page itself), you need to create a template/template part and manage it trough wordpress's apis (which includes, as said, shipping it as a template part or a template itself, See codex )如果您需要将其嵌入现有页面(或新页面本身),则需要创建模板/模板部分并通过 wordpress 的 api 对其进行管理(如上所述,其中包括将其作为模板部分或模板本身发送, 见法典)
  2. If you need to create a new page with custom logic which is more suitable to be written as a plugin, consider adding a rewrite rule to a custom route (See this section of the codex and take a look at this article )如果你需要新建一个自定义逻辑的新页面,更适合作为插件编写,可以考虑在自定义路由中添加重写规则(参见codex的这个部分,看看 这篇文章

that is i want这就是我想要的

when enter to site/wp-content/themes/admin/dashboard/login当进入站点/wp-content/themes/admin/dashboard/login

rewrite to改写为

site/wp-content/themes/admin/dashboard/?url=login网站/wp-content/themes/admin/dashboard/?url=login

login not static登录不是静态的

now i use this to htaccess but don't work :现在我用它来 htaccess 但不起作用:

RewriteRule ^wp-content/themes/bluetheme/dashboard/(.*)$ /subdirectory/wp-content/themes/bluetheme/dashboard?url=$1 [L,NC,QSA]

Don't try cheating on WP, by smuggling your php file in some dir and trying to call it from there, by tweaking .htaccess file and similar.不要试图欺骗 WP,通过在某个目录中走私您的 php 文件并尝试从那里调用它,通过调整 .htaccess 文件和类似文件。 Look for system way to create custom WP page.寻找系统方式来创建自定义 WP 页面。 Ie IE

https://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/ https://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM