[Resolved] Remove word "Category" from title of category page

  • Author
    Posts
  • #6011

    Rutger
    Participant

    Hi there,

    Just on the brink of launching my website, but I do have one more question. I haven’t been able to find the answer on general WordPress discussions online – and hoped perhaps you are able to help out.

    I use multiple categories of messages and use a category page to display all my messages of the ‘news’ variety: see: http://demodernetijd.nl/nieuws/. This works fine, but I would like my page to say “News” rather than “Category: News” in the page title. Is there a way to remove the text “Category: ” (my page is in Dutch, so actually ‘Categorie: “)?

    Best wishes,

    Rutger

    #6013

    Andrew Misplon
    Keymaster

    Hi Rutger

    Thanks for posting. Sure, we can edit the prefix, please, try the following:

    1. Plugins > Add New, search for and install: Code Snippets.
    2. Go to Snippets > Add New, name the snippet as required and insert into the body:

    function ultra_archive_title( $title ) {
    	if ( is_category() ) {
    		$title = single_cat_title( '', false );
    	} elseif ( is_tag() ) {
    		$title = single_tag_title( '', false );
    	} elseif ( is_author() ) {
    		$title = '<span class="vcard">' . get_the_author() . '</span>' ;
    	}
    	return $title;
    }
    add_filter( 'get_the_archive_title', 'ultra_archive_title' );

    Scroll to the bottom of the page and enable the option labelled: Only run on site front-end. Finally, click Save changes and activate.

    Hope that helps.

    #6014

    Rutger
    Participant

    Dear Andrew,

    This is marvellous, couldn’t possibly have come up with this myself. Many thanks!!

    Best wishes,

    Rutger

    #6015

    Andrew Misplon
    Keymaster

    Super 🙂 Glad to hear that did the trick. Chat soon. Cheers.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Scroll to top