• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Add "title" in "archive" pages, like category or tag's lists

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Add "title" in "archive" pages, like category or tag's lists

This topic is: not resolved

Tagged: archive, category, snippet, tag, title

  • This topic has 4 replies, 2 voices, and was last updated 9 years, 9 months ago by DanielMT.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • June 28, 2016 at 2:08 am #188424
    DanielMT
    Participant

    Hi,

    I'm wondering if there's a way to display a page "title" when a "category" or "tag" archives are displayed. For example, take a look at this screenshot: https://www.evernote.com/l/AGx02-IiV59I_rv_53YFX-NADcHiyn3y7ow

    This is what the user will see when clicking a post's tag. The same for a category. Is there a way to show such a title? For example: "Recipes from the category XXXXXXXX"

    Just a snippet to add in the functions.php file.

    Thanks in advance,
    Daniel

    June 28, 2016 at 9:08 am #188446
    Christoph
    Member

    Hi Daniel,

    that´s built-in functionality.

    Go to Posts - Categories - Edit the category - Scroll down to Category Archive Settings
    And enter an Archive Headline.
    http://prntscr.com/bm5zsi
    Click Update

    Looks like this:
    http://prntscr.com/bm601j

    It's the same for Tags


    https://www.christophherr.com | Genesis Customizations | Buy me a coffee

    June 28, 2016 at 9:13 am #188448
    DanielMT
    Participant

    Hi Christoph,

    Thanks for the answer.
    I know about that functionality, but I have more than a hundred tags and I don't want to edit one by one just to add that title. I'm looking for doing it with a simple snippet.

    Thanks,
    Daniel.

    June 28, 2016 at 9:55 am #188453
    Christoph
    Member

    Hi Daniel,

    that makes a lot of sense 🙂

    Bill Erickson to the rescue:
    (I just added the 'Recipies from the ' before the term name 😉 )
    http://prntscr.com/bm6nns

    /**
     * Default Titles for Term Archives
     *
     * @author Bill Erickson
     * @see http://www.billerickson.net/default-category-and-tag-titles
     *
     * @param string $headline
     * @param object $term
     * @return string $headline
     */
    function ea_default_term_title( $value, $term_id, $meta_key, $single ) {
    	if( ( is_category() || is_tag() || is_tax() ) && 'headline' == $meta_key && ! is_admin() ) {
    
    		// Grab the current value, be sure to remove and re-add the hook to avoid infinite loops
    		remove_action( 'get_term_metadata', 'ea_default_term_title', 10 );
    		$value = get_term_meta( $term_id, 'headline', true );
    		add_action( 'get_term_metadata', 'ea_default_term_title', 10, 4 );
    		// Use term name if empty
    		if( empty( $value ) ) {
    			$term = get_term_by( 'term_taxonomy_id', $term_id );
    			$value = 'Recipies from the ' . $term->name;
    		}
    
    	}
    	return $value;
    }
    add_filter( 'get_term_metadata', 'ea_default_term_title', 10, 4 );

    https://www.christophherr.com | Genesis Customizations | Buy me a coffee

    June 29, 2016 at 2:29 am #188507
    DanielMT
    Participant

    Thanks for your suggestion, but didn't work fine.

    Finally, I've built this snippet and put it in a hook using Genesis Simple Hooks:

    <?php
    
    if (is_category()) {
        echo '<h1 class="entry-title" itemprop="headline">Recipes from the category "' . single_term_title("", false) . '"</h1>';
    }
    
    if (is_tag()) {
        echo '<h1 class="entry-title" itemprop="headline">Recipes tagged with "' . single_term_title("", false) . '"</h1>';
    }
    
    ?>

    Regards.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble