[Resolved] Can't change title of archive page

Home Forums Support Can't change title of archive page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1050468
    Mark

    I have read all through this forum, and done other internet searches. I have tried at least a dozen variations of suggested code, but I cannot get the title of a post category archive page to change.
    The post category is “Latest”. When I add /latest/ to the end of our site URL, that is what is shown on the archive page. I want to change that title to “NCGS Announcements Archive”.

    For example:

    add_filter( ‘get_the_archive_title’,’ncgs_latest_archive_title’, 10, 1 );

    function ncgs_latest_archive_title($title){
    if (is_category(‘latest’) ) $title = ‘NCGS Announcements Archive’;
    return $title;
    }

    Also tried:

    add_filter( ‘get_the_archive_title’, function ($title) {
    if ( is_category(‘latest’) ) {
    $title = ‘NCGS Announcements Archive’;
    return $title;
    }});

    And:

    function change_latest_title( $title ){
    if ( $title == ‘Latest’ ) $title = ‘NCGS Announcements Archive’;
    return $title;
    }
    add_filter( ‘get_the_archive_title’, ‘change_latest_title’ );

    And many variations similar to these.

    I have the Code Snippets plugin installed, and it works very well for for making changes like this. So I am not trying to overwrite actual GP code. I’m using GeneratePress 2.3.2 and GP Premium 1.8.3

    After spending most of a day trying things that don’t work, I’m just stumped. I’m hoping you can help me out here.

    Thanks in advance for any assistance.

    #1051082
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Give this a shot:

    add_filter( 'get_the_archive_title', function( $title ) {
        if ( is_category( 'latest' ) ) {
            $title = 'Your title';
        }
    
        return $title;
    }, 50 );

    Let me know 🙂

    #1051217
    Mark

    That worked! I was even able to add another IF statement to the same code snippet to change two different archive titles.
    Thanks so much, Tom!

    – Mark

    #1051456
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.