php - Wordpress div 未显示在站点的本地主机版本上

标签 php html css wordpress

我有一个站点的 2 个版本,一个实时测试版本和一个本地版本。

我目前正在使用 MAMP 开发本地版本。两个站点的后端是相同的,我确保每个站点的管理员完全相同。

我正在尝试通过编辑页面 部分向站点添加图像,但图像没有显示。

我检查了该站点以查看任何错误,没有发现任何错误,但是我遇到了一些有趣的事情。

并排比较两个站点版本的 html 标记后,我注意到我的本地版本缺少显示图像的 div。

这里是 live 版本的 div -

enter image description here

这是我的本地版本,其中没有显示 div - enter image description here

正如您在本地版本中看到的那样,有一个 ul 而不是 div class="image-16-8

这是显示这些图像的 php 文件

    <?php

function tbhHeroShortcode($atts)
{

    $values = shortcode_atts(array(
        'images' => '',
        'first-line' => '',
        'second-line' => '',
        'video' => '',
        'link' => '',
    ), $atts);
    ob_start();
    ?>
    <div class="hero">
        <?
        $images = decode_shortcode_data($values['images']);
        if ($images): ?>
            <ul data-simple-slider>
                <?php foreach ($images as $image): ?>
                    <li>
                        <div class="image-16-8" style="background-image: url(<?= $image->url; ?>); "></div>
                    </li>
                <?php endforeach; ?>
            </ul>
        <?php endif; ?>
        <div class="hero-content">
            <div class="hero-content-first-line">
                <h1 class="header"><?= decode_shortcode_data($values['first-line']) ?></h1>

            </div>
            <h1 class="italic-header"><?= decode_shortcode_data($values['second-line']) ?></h1>

            <div class="hero-content-cta">
                <a class="hollow-button" href="<?= decode_shortcode_data($values['link']) ?>">Learn More</a>

            </div>

        </div>

        <?php if (count($images) > 1): ?>
            <div class="hero-controls">
                <i class="fa fa-chevron-left hero-controls__left" aria-hidden="true"></i>
                <i class="fa fa-chevron-right hero-controls__right" aria-hidden="true"></i>
            </div>
        <?php endif; ?>
    </div>
    <?php
    $component = ob_get_contents();
    ob_end_clean();
    return $component;
}

add_shortcode('tbhHero', 'tbhHeroShortcode');

有人知道为什么会这样吗?

最佳答案

显示 ul 是因为它就在您的 php 中

<div class="hero">
    <?
    $images = decode_shortcode_data($values['images']);
    if ($images): ?>
        <ul data-simple-slider>

但是,在您的实时版本截图中,您的英雄 div 不同,它看起来像这样

<div class="hero" id>

您看到的输出不是由同一个文件生成的,因此要么存在一些浏览器/服务器缓存正在进行并且您从实时站点看到的内容不反射(reflect)您的 php 的当前状态,要么您的 php 以某种方式两个环境之间的文件更新不同步。

关于php - Wordpress div 未显示在站点的本地主机版本上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47060135/

相关文章:

jquery - 切换工作,但不在 Bootstrap 3 上设置动画

html - CSS - 任何大小图像的相对大小(比例)

css - 仅从 anchor 元素子元素中删除下划线

php - 在浏览其他页面时上传多个文件 - 如何?

php - 在自动生成的列和行中加载 mysql 数据

php - 我的 javascript 函数没有重定向到其他页面

javascript - Div 在 div 之上而不是在彼此之下

javascript - 将一次潜水的完整 html 附加到新的 div

html - asp.net 如何使用超链接将数据从一页显示到另一页

php - 如何在忽略键的同时组合两个 PHP 数组