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

Only display archive subtitle on the first archive page

programmeradmin3浏览0评论

I would like to only display the archive subtitle on the first archive page. Now, it shows at the top of every page.

I am putting a lot of information with direct links in the subtitle of the tags (it's actually a custom taxonomy if that matters).

So basically the first archive page will give the user possibly all the information and specific links to posts that they may need.

However, the archive pages will provide a comprehensive way to find all the content that may have that tag.

Currently, index.php seems to be what is generating my archive pages.

I'm guessing this is the part I need to modify:

if ( $archive_title || $archive_subtitle ) {
    ?>
    <header class="archive-header has-text-align-center header-footer-group">
        <div class="archive-header-inner section-inner medium">
            <?php if ( $archive_title ) { ?>
                <h1 class="archive-title"><?php echo wp_kses_post( $archive_title ); ?></h1>
            <?php } ?>
            <?php if ( $archive_subtitle ) { ?>
                <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div>
            <?php } ?><hr class="archive-head-separator styled-separator">
        </div>
    </header>
    <?php
}

Is there a way to know what page of the archive it's on and somehow work that into an if statement around this bit?

if ( $archive_subtitle ) { ?>
    <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div>
}

Is that right?

I would like to only display the archive subtitle on the first archive page. Now, it shows at the top of every page.

I am putting a lot of information with direct links in the subtitle of the tags (it's actually a custom taxonomy if that matters).

So basically the first archive page will give the user possibly all the information and specific links to posts that they may need.

However, the archive pages will provide a comprehensive way to find all the content that may have that tag.

Currently, index.php seems to be what is generating my archive pages.

I'm guessing this is the part I need to modify:

if ( $archive_title || $archive_subtitle ) {
    ?>
    <header class="archive-header has-text-align-center header-footer-group">
        <div class="archive-header-inner section-inner medium">
            <?php if ( $archive_title ) { ?>
                <h1 class="archive-title"><?php echo wp_kses_post( $archive_title ); ?></h1>
            <?php } ?>
            <?php if ( $archive_subtitle ) { ?>
                <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div>
            <?php } ?><hr class="archive-head-separator styled-separator">
        </div>
    </header>
    <?php
}

Is there a way to know what page of the archive it's on and somehow work that into an if statement around this bit?

if ( $archive_subtitle ) { ?>
    <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div>
}

Is that right?

Share Improve this question edited Mar 24, 2020 at 20:55 WordPress Speed 2,2833 gold badges19 silver badges34 bronze badges asked Mar 24, 2020 at 11:45 HopefullCoderHopefullCoder 456 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

is_paged() can be used to tell if you are on any page other than the first page of an archive. You could use it like this:

<?php if ( $archive_subtitle && ! is_paged() ) { ?>
    <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div>
<?php } ?>
发布评论

评论列表(0)

  1. 暂无评论