php - 在非 wordpress 网站上显示 wordpress 页脚

标签 php html wordpress echo footer

我想问一个简短的问题。我有两个网站在同一个域上运行。主页是完整的 HTML,可以通过访问 http://xyz.com/home 访问。至于内页,我在同一个域上安装了wordpress,可以通过转到http://xyz.com/sample-page访问这些页面。 .现在我在 wordpress 中创建了一个页脚,它在运行 wordpress 的内页上正确显示,但我也想在我的 HTML 页面上显示完全相同的页脚,但它没有运行 wordpress。为此,我在主页的 index.php 文件中添加了以下代码:

<footer>
<?php include '../wp-content/themes/metro/footer.php'; ?>
</footer>

这样做现在在主页上向我显示此错误:

Fatal error: Call to undefined function get_option() in /homepages/12/d378078258/htdocs/txtimpact-main/wp-content/themes/metro/footer.php on line 1

任何人都可以告诉我如何修改 footer.php 文件,以便页脚开始出现在我的主页上。我在互联网上阅读了一个教程,其中有人告诉我将这段代码添加到 footer.php 文件中,但它对我的情况没有帮助:

require( '../my_wordpress_install_root/wp-load.php' );

这就是为什么我的 footer.php 文件包含的代码:

<?php $options = get_option('metro'); ?>
    </div><!--#page-->
</div><!--.container-->
</div>
    <footer>
        <div class="container">
            <div class="footer-widgets">
                <?php widgetized_footer(); ?>
                <img style="position:absolute; visibility:show; left: -6px; top: 84px; } " src="http://cms.360ivr.com/wp-content/themes/metro/images/callout-bubble.png" width="22px" />
            </div><!--.footer-widgets-->
        </div><!--.container-->
    <h12><?php mts_copyrights_credit(); ?></h12>
    <div style="float: left; margin-top: 20px; margin-left: 153px;"><font size="2px">Copyright © 2006-12 TXTImpact - All Rights Reserved.<br/>Message and Data Rates may apply.<br/>To unsubscribe, text 'STOP' to 27126 or <a href="mailto:support@TXTimpact.com">Contact Support</a>.<br/><a href="http://www.wire2air.com/" target="_blank">Powered by Wire2Air</a><br/><a href="http://nytm.org/made/" target="_blank">Proudly Made In NYC</a></font></div> 
    <div style="margin-right: 83px; margin-top: 91px;"><img src="http://cms.360ivr.com/wp-content/uploads/2013/03/mma1.png" width="450px" align="right" /></div>
    </footer><!--footer-->
<?php mts_footer(); ?>
<?php wp_footer(); ?>
</body>
</html>

最佳答案

您的主页http://xyz.com/home不能使用 WordPress 函数(如果你想要它们,你必须手动包含它们)。我建议您使用 WordPress 来显示主页。 WordPress 具有将特定页面显示为主页的设置。

引自 the WordPress codex :

What Template is Used to Display a Particular Page? WordPress looks for several Page template files in your active WordPress Theme based upon the Template Hierarchy. The first one it finds will be used to display any given Page. WordPress will look for files in the following order:

页面选择的“页面模板”

page.php

index.php

WordPress 模板层次结构还可以自动识别特定的页面或帖子,而无需将它们分配给特定的页面模板文件。如果用户创建了模板文件名中带有 ID 或 slug 的页面,则会自动使用相应的页面模板文件。

page-{id}.php

page-{slug}.php

如果页面 ID 号为 42,则自动使用 page-42.php 模板文件。如果页面 slug 是“关于”,则使用 page-about.php 模板文件。

关于php - 在非 wordpress 网站上显示 wordpress 页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15448011/

相关文章:

javascript - 如何在yii中的div onclick中加载页面?

php - Laravel:错误 "The page has expired due to inactivity"(419 未知状态)

javascript - 如何防止点击通过固定定位元素传递到它后面的元素?

javascript - Angular uibModal,解析,未知提供者

php - 如何从克隆的 laravel 项目生成迁移(表?)到本地数据库?

php - 检查字符串是否包含特定数字

php - 无法加载 localhost php 文件的源代码

html - 悬停时图像映射更改图像

css - 如何为 NextGen masonry gallery 设置图像大小

PHP + CSS : Output Options Framework Content