[Resolved] Renaming The Archive Title

Home Forums Support [Resolved] Renaming The Archive Title

Home Forums Support Renaming The Archive Title

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1586428
    Jonathan

    I was hoping for a cleaner way to rename the archive title by dropping, in this case, the category that the term is associated with. In this case the taxonomy is called Research Category followed by the term IHA-C. The code I’m using is this:

    echo str_replace('Research Category :','', get_the_archive_title());

    Which strips out the Research Category : part.

    Is there a better way?

    J

    #1586658
    Leo
    Staff
    Customer Support

    Hi there,

    That looks good to me ๐Ÿ™‚

    I think you can also use the filter like this:
    https://generatepress.com/forums/topic/how-to-add-a-suffix-to-the-category-archive-title/#post-1274566

    #1586831
    Jonathan

    Thanks for the link. I looked at the wordpress codex and used this as I wanted to remove the prefix label of the taxonomy:

    function antibody_archive_title( $title ) {
     if ( is_category() ) {
            $title = single_cat_title( '', false );
        } 
         elseif ( is_tax() ) {
            $title = single_term_title( '', false );
        }
      
        return $title;
    }
     
    add_filter( 'get_the_archive_title', 'antibody_archive_title' );
    #1587481
    Leo
    Staff
    Customer Support

    Glad to hear!

    No problem ๐Ÿ™‚

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