Community Forums › Forums › Archived Forums › General Discussion › Automatic Tag Archive Headline
Tagged: headline, tag archive, tags
- This topic has 5 replies, 2 voices, and was last updated 10 years, 8 months ago by Gary Jones.
-
AuthorPosts
-
August 20, 2013 at 6:53 am #57498Brain916Member
Hello,
Another thing I noticed was in order for Archive Headlines to show up you had to manually place the title of the page on each tag. For my website I have 1000s of tags and would take forever to do this...Is there a way (shown here: http://test.sneakerfiles.com/?tag=nike-kd-vi) for it to automatically show up, whatever the title of the tag is? I know if I want to edit or add to it I need to go in manually though.Thanks again for reading.
http://test.sneakerfiles.com/?tag=nike-kd-viAugust 21, 2013 at 5:56 am #57875Brain916MemberCan anyone please help me with this?
August 21, 2013 at 6:02 am #57879Gary JonesMemberDon't reply to your own posts - it knocks them off of the Unanswered Posts list.
Try the following in your functions.php file:
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 ); add_action( 'genesis_before_loop', 'genesis_automatic_term_headline_do_taxonomy_title_description', 15 ); /** * Change the behaviour of the default term headline, by making the default the name of the term. * * If the headline has been customised in some way, hen this will show instead. * * @author Gary Jones, Gamajo Tech * * @return null Return early if not the correct archive page, not page one, or no term meta is set. */ function genesis_automatic_term_headline_do_taxonomy_title_description() { global $wp_query; if ( ! is_category() && ! is_tag() && ! is_tax() ) return; if ( get_query_var( 'paged' ) >= 2 ) return; $term = is_tax() ? get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ) : $wp_query->get_queried_object(); if ( ! $term || ! isset( $term->meta ) ) return; $headline_text = $term->meta['headline'] ? $term->meta['headline'] : $term->name; $headline = sprintf( '<h1 class="archive-title">%s</h1>', strip_tags( $headline_text ) ); $intro_text = $term->meta['intro_text'] ? apply_filters( 'genesis_term_intro_text_output', $term->meta['intro_text'] ) : ''; printf( '<div class="archive-description taxonomy-description">%s</div>', $headline . $intro_text ); }
I'll turn it into a plugin later on.
WordPress Engineer, and key contributor the Genesis Framework | @GaryJ
August 21, 2013 at 6:40 am #57893Gary JonesMemberPlugin now created: https://github.com/GaryJones/genesis-automatic-term-headline
WordPress Engineer, and key contributor the Genesis Framework | @GaryJ
August 22, 2013 at 4:08 am #58152Brain916MemberThis worked perfectly! I dropped it into the functions.php instead of using the plugin. Thank you so much, you are awesome my friend!
August 22, 2013 at 4:40 am #58154Gary JonesMemberThe trouble with not using the plugin, is that should you ever change themes, that headline content is going to disappear. With a plugin however, it will persist, and could also be used across other sites as well. There's no disadvantage to using the plugin here.
WordPress Engineer, and key contributor the Genesis Framework | @GaryJ
-
AuthorPosts
- The topic ‘Automatic Tag Archive Headline’ is closed to new replies.