首页 > 解决方案 > 嵌套的 php 包含文件 - 不显示内容 Wordpress

问题描述

我有一些 php 包含文件,它们将内容拉到我的主页,例如 header.php

在这些 php 文件中,我有其他 php 包含调用设计的不同元素。

在我将平面 HTML 文件转换为 Wordpress 主题目录之前,它会显示得非常好。

主 header.php 文件显示,但其中包含的任何 php 文件均不显示。请有人帮忙。

这是一个 php 文件 header-withbooker.php 的示例

<?php include 'includes/content/headers/with-booker.php';?>

在这个文件中,它看起来像:

    <?php include 'includes/content/nav/top-nav.php';?>

    <div class="container">
        <div class="full-header">
            <?php include 'includes/content/rating-box.php';?>
            <h1>Your journey begins here</h1>
            <h2>4-90 seater vehicles &amp; drivers available worldwide</h2>
        </div>
    </div>

</header>
<!-- Close Header Box -->

<?php include 'includes/content/booking/main-booker.php';?>

知道我做错了什么吗?

先感谢您

标签: phpwordpress

解决方案


您可以在 WordPress 中包含文件,例如:

get_template_part( 'includes/content/headers/', 'withbooker' );
get_template_part( 'includes/content/nav/', 'top-nav' );
get_template_part( 'includes/content/booking/', 'main-booker' );

希望这对你有用。


推荐阅读