Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WordPressPHP-如何在每个页面上显示标题图像?_Php_Wordpress - Fatal编程技术网

WordPressPHP-如何在每个页面上显示标题图像?

WordPressPHP-如何在每个页面上显示标题图像?,php,wordpress,Php,Wordpress,以前有人问过类似的问题,但我尝试了所有建议的解决方案,但都没有成功。我的Wordpress站点在主页上有一个标题图像,但它并没有显示在每个页面上。我尝试使用一个独特的Headers插件,尝试为我的每个页面创建一个不同的.php文件来显示标题图像(例如header about.php),但没有成功。我在header.php文件中发现了这段代码,我认为需要对其进行更改,但我对php不是很熟悉。我试图改变一些主张,但它要么没有做任何事情,要么破坏了网站 这是header.php文件中标题图像的代码:

以前有人问过类似的问题,但我尝试了所有建议的解决方案,但都没有成功。我的Wordpress站点在主页上有一个标题图像,但它并没有显示在每个页面上。我尝试使用一个独特的Headers插件,尝试为我的每个页面创建一个不同的.php文件来显示标题图像(例如header about.php),但没有成功。我在header.php文件中发现了这段代码,我认为需要对其进行更改,但我对php不是很熟悉。我试图改变一些主张,但它要么没有做任何事情,要么破坏了网站

这是header.php文件中标题图像的代码:

<div <?php post_class( 'featured-' . $count ); ?>>
                        <!-- Page content stuff end -->
                        <?php if ( is_front_page() ) : ?>
                            <!-- Header img -->
                            <div class="header-content-wrap-outer">
                                <div class="header-content-wrap">
                                    <div class="bottom-header-title"><?php the_title(); ?></div>
                                    <div class="bottom-header-paragraph"> <?php esc_html_e('Written', 'wordly') ?> <?php echo get_the_date(); ?></div>
                                    <!-- Button-->
                                    <div class="buttons-wrapper">
                                        <a href="<?php the_permalink() ?>" class="header-button-solid"><?php esc_html_e('READ MORE', 'wordly') ?></a>
                                    </div>
                                    <!--Buttons -->
                                </div>
                            </div>
                        <?php endif; ?>
                        <!-- / Header img -->
                        <!-- Header content end -->
                        <!-- Page content stuff start -->
                    </div>
                    <?php
                    $count++;
                endwhile;
            endif;
            wp_reset_postdata();
            ?>
            <!-- Page content stuff end -->
            <!-- Header bg start-->
        </header>


在您的“标题图像”html标记中没有
img
标记。由于img src标记不存在,因此可以在其中一个类中将图像设置为背景图像属性。您可以通过检查元件进行确认。此外,此函数
是_front_page()
用于检查主页并呈现标题图像。如果希望图像在所有页面中统一显示,可以删除此条件并编辑代码。