试图将博客标题放在夸克上的特色图片下面

时间:2017-02-15 14:56:29

标签: php wordpress wordpress-theming

我一直在尝试将博客标题放在博客帖子下面的定制夸克主题上。但是,每次我都会得到一个空白的博客帖子页面(标题除外)

代码是:

<header class="entry-header">
            <?php if ( is_single() ) { ?>
                <h1 class="entry-title"><?php the_title(); ?></h1>
            <?php }
            else { ?>
                <h1 class="entry-title">
                    <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to ', 'quark' ) . '%s', the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
                </h1>
            <?php } // is_single() ?>
            <?php quark_posted_on(); ?>
            <?php if ( has_post_thumbnail() && !is_search() ) { ?>
                <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to ', 'quark' ) . '%s', the_title_attribute( 'echo=0' ) ) ); ?>">
                    <?php the_post_thumbnail( 'post_feature_full_width' ); ?>
                </a>
            <?php } ?>

我将其更改为:

<header class="entry-header">
                    <?php } // is_single() ?>
            <?php quark_posted_on(); ?>
            <?php if ( has_post_thumbnail() && !is_search() ) { ?>
                <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to ', 'quark' ) . '%s', the_title_attribute( 'echo=0' ) ) ); ?>">
                    <?php the_post_thumbnail( 'post_feature_full_width' ); ?>
                </a>

    <?php if ( is_single() ) { ?>
                <h1 class="entry-title"><?php the_title(); ?></h1>
            <?php }
            else { ?>
                <h1 class="entry-title">
                    <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to ', 'quark' ) . '%s', the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
                </h1>

            <?php } ?>

我也尝试了几种变体,但收效甚微。我确信我是愚蠢的,但任何帮助都会很棒。

谢谢!

2 个答案:

答案 0 :(得分:1)

尝试以下内容(基于我的上述第一个答案和评论):

<header class="entry-header">
        <?php quark_posted_on(); ?>
        <?php if ( has_post_thumbnail() && !is_search() ) { ?>
            <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to ', 'quark' ) . '%s', the_title_attribute( 'echo=0' ) ) ); ?>">
                <?php the_post_thumbnail( 'post_feature_full_width' ); ?>
            </a>
        <?php } ?>
<?php if ( is_single() ) { ?>
            <h1 class="entry-title"><?php the_title(); ?></h1>
        <?php }
        else { ?>
            <h1 class="entry-title">
                <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to ', 'quark' ) . '%s', the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
            </h1>

        <?php } ?>

答案 1 :(得分:0)

第二行可能会导致问题,除非有相应的{某处?