Joshua David Nelson

Bullshit Free WordPress Development

  • Services
  • Code
  • About
  • Contact

Default Category and Tag Archive Titles in Genesis 2.2.7

After version 2.2.7 Genesis utilizes the new core get_term_meta to grab the category headline and intro text. This snippet uses the term name for a default value of the headline term meta.

<?php
/**
* 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 );
if( $term ) {
$value = $term->name;
}
}
}
return $value;
}
add_filter( 'get_term_metadata', 'ea_default_term_title', 10, 4 );
view raw default-tax-archive-title.php hosted with ❤ by GitHub

Source: https://gist.github.com/joshuadavidnelson/a0ad40ead9e724f87b0e8ee955dd3c60

Tags: Genesis, metadata, Taxonomy, term meta

Previous Code:
Pure CSS Parallax Page Header in Genesis
Back to the Code Snippets
Next Code:
Rename WooCommerce “Brands” to “Manufacturers”
  • Twitter
  • RSS Feed URL

About Me

I'm a WordPress Engineer. I build sleek, custom websites with WordPress and Genesis.

See my services and my recent work.

Contact me to get your project started.

Gravity Forms Plugin for WordPress Fastest WordPress Hosting

Recent Posts

  • Using Font Awesome Icons for WooCommerce Grid / List Toggle
  • Disable Blog: WordPress Gone Blog-less
  • Category (Taxonomy) Dropdown Filtered By Post Type
  • Weather in WordPress with Dark Sky
  • Fixing Your Deprecated Widget Constructors in WordPress 4.3
  • Twitter
  • RSS Feed URL
  • Code Snippets
  • My Plugins
  • Make a Payment

© Joshua David Nelson | Hand-Forged | WordPress + Genesis | Terms of Service | Legal | Contact