最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

post thumbnails - How do I get the featured image to sit below the header in the twenty nineteen theme?

programmeradmin0浏览0评论

In the twentynineteen theme, the featured image in a post becomes the background of the post. Actually, it becomes the background of the header. I'm trying to get it sit below the header in each post as in the default front page.

What is the minimum lines I need to change to make this happen?

Here is the relevant portion of header.php....

<body <?php body_class(); ?>>
<div id="page" class="site">
    <a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'twentynineteen' ); ?></a>

        <header id="masthead" class="<?php echo is_singular() && twentynineteen_can_show_post_thumbnail() ? 'site-header featured-image' : 'site-header'; ?>">

            <div class="site-branding-container">
                <?php get_template_part( 'template-parts/header/site', 'branding' ); ?>
            </div><!-- .layout-wrap -->

            <?php if ( is_singular() && twentynineteen_can_show_post_thumbnail() ) : ?>
                <div class="site-featured-image">
                    <?php
                        twentynineteen_post_thumbnail();
                        the_post();
                        $discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentynineteen_get_discussion_data() : null;

                        $classes = 'entry-header';
                        if ( ! empty( $discussion ) && absint( $discussion->responses ) > 0 ) {
                            $classes = 'entry-header has-discussion';
                        }
                    ?>
                    <div class="<?php echo $classes; ?>">
                        <?php get_template_part( 'template-parts/header/entry', 'header' ); ?>
                    </div><!-- .entry-header -->
                    <?php rewind_posts(); ?>
                </div>
            <?php endif; ?>
        </header><!-- #masthead -->

    <div id="content" class="site-content">

In the twentynineteen theme, the featured image in a post becomes the background of the post. Actually, it becomes the background of the header. I'm trying to get it sit below the header in each post as in the default front page.

What is the minimum lines I need to change to make this happen?

Here is the relevant portion of header.php....

<body <?php body_class(); ?>>
<div id="page" class="site">
    <a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'twentynineteen' ); ?></a>

        <header id="masthead" class="<?php echo is_singular() && twentynineteen_can_show_post_thumbnail() ? 'site-header featured-image' : 'site-header'; ?>">

            <div class="site-branding-container">
                <?php get_template_part( 'template-parts/header/site', 'branding' ); ?>
            </div><!-- .layout-wrap -->

            <?php if ( is_singular() && twentynineteen_can_show_post_thumbnail() ) : ?>
                <div class="site-featured-image">
                    <?php
                        twentynineteen_post_thumbnail();
                        the_post();
                        $discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentynineteen_get_discussion_data() : null;

                        $classes = 'entry-header';
                        if ( ! empty( $discussion ) && absint( $discussion->responses ) > 0 ) {
                            $classes = 'entry-header has-discussion';
                        }
                    ?>
                    <div class="<?php echo $classes; ?>">
                        <?php get_template_part( 'template-parts/header/entry', 'header' ); ?>
                    </div><!-- .entry-header -->
                    <?php rewind_posts(); ?>
                </div>
            <?php endif; ?>
        </header><!-- #masthead -->

    <div id="content" class="site-content">
Share Improve this question asked Jan 4, 2019 at 1:13 F. EsavF. Esav 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

You need to add a filter to your functions.php theme: add_filter('twentynineteen_can_show_post_thumbnail', '__return_false');

发布评论

评论列表(0)

  1. 暂无评论