简单PHP网站中的Wordpress主题代码

发布于 2024-12-06 03:00:47 字数 216 浏览 4 评论 0原文

我有一个 php 网站,在其中我使用了很多 jquery 插件并动态访问另一个数据库以获取页眉和页脚内容。现在我必须添加一个正在检查 wordpress 的博客。我可以创建主题,但无法从其他数据库访问页眉和页脚动态内容。在我的简单 php 页面中是否有其他方法可以访问 wordpress 主题循环和其他主题功能?如果没有,那么请建议在网站中添加其他简单的 php 博客脚本并提供 SEO 支持。

谢谢

I have a php website, in which I have used a lot of jquery plugins and accessing another database for header and footer contents dynamically.Now I have to add a blog for which I am checking wordpress. I can create the theme, but cannot access the header and footer dynamic contents from other DB. Is there some other to access the wordpress theme loop and other theme functions in my simple php pages? If no then any suggestion about other simple php blog script to add in the website with SEO support please.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟织青萝梦 2024-12-13 03:00:47

您可以根据需要使用 include() 或 require() 在 WordPress 模板中包含文件。只需将 PHP 文件与模板文件放在一起就可以了。

如果您的旧网站现在位于模板文件夹中,您可以通过以下方法完全放弃 WordPress 并显示旧网站中的某些内容:

add_action('template_redirect', 'show_old_page');
function show_old_page() {
    if( $_GET['old_page'] == 'pagename' ) {
        include( TEMPLATE_PATH . 'oldpage.php' );
        exit;
    }
}

You can include files as you wish in a Wordpress template using include() or require(). Just put your PHP files with your template files and you should be good to go.

Here's how you can forego Wordpress entirely and display something from your old website, if your old website now lives inside of your template folder:

add_action('template_redirect', 'show_old_page');
function show_old_page() {
    if( $_GET['old_page'] == 'pagename' ) {
        include( TEMPLATE_PATH . 'oldpage.php' );
        exit;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文