• 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

Default meta description to home description if emtpy

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 › Default meta description to home description if emtpy

This topic is: not resolved
  • This topic has 3 replies, 2 voices, and was last updated 11 years, 5 months ago by LeifQ.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • February 16, 2015 at 2:46 pm #141044
    WhiteleyDesigns
    Member

    Out of curiosity - what are other developers doing with regards to the meta description output on pages and posts? I know you can manually add the meta description using the on-page SEO options for any pages, posts, etc...but when that is left blank I've had to create a function to fallback to the home meta description just to the page has a description as it shouldn't be neglected.

    The situation I've run into is when I am asked to work on larger sites and covert them into a Genesis Framework site I don't want to spend the time going through every single page and customizing the meta description. I do it for all the important pages, but I don't believe it is necessary for all pages. I've used the following as a fallback - it is the same genesis_seo_meta_description except that I added a check to see if it is blank, and if so return the home meta description.

    It works fine - but I'm curious what others are doing.

    // Add main site description on any page that doesn't have a customized description
    remove_action( 'genesis_meta', 'genesis_seo_meta_description' );
    add_action( 'genesis_meta', 'wd_genesis_seo_meta_description' );
    function wd_genesis_seo_meta_description() {
    	global $wp_query;
    	$description = '';
    	//* If we're on the home page
    	if ( is_front_page() )
    		$description = genesis_get_seo_option( 'home_description' ) ? genesis_get_seo_option( 'home_description' ) : get_bloginfo( 'description' );
    	//* If we're on a single post / page / attachment
    	if ( is_singular() ) {
    		//* Description is set via custom field
    		if ( genesis_get_custom_field( '_genesis_description' ) )
    			$description = genesis_get_custom_field( '_genesis_description' );
    		//* All-in-One SEO Pack (latest, vestigial)
    		elseif ( genesis_get_custom_field( '_aioseop_description' ) )
    			$description = genesis_get_custom_field( '_aioseop_description' );
    		//* Headspace2 (vestigial)
    		elseif ( genesis_get_custom_field( '_headspace_description' ) )
    			$description = genesis_get_custom_field( '_headspace_description' );
    		//* Thesis (vestigial)
    		elseif ( genesis_get_custom_field( 'thesis_description' ) )
    			$description = genesis_get_custom_field( 'thesis_description' );
    		//* All-in-One SEO Pack (old, vestigial)
    		elseif ( genesis_get_custom_field( 'description' ) )
    			$description = genesis_get_custom_field( 'description' );
    	}
    	if ( is_category() ) {
    		//$term = get_term( get_query_var('cat'), 'category' );
    		$term = $wp_query->get_queried_object();
    		$description = ! empty( $term->meta['description'] ) ? $term->meta['description'] : '';
    	}
    	if ( is_tag() ) {
    		//$term = get_term( get_query_var('tag_id'), 'post_tag' );
    		$term = $wp_query->get_queried_object();
    		$description = ! empty( $term->meta['description'] ) ? $term->meta['description'] : '';
    	}
    	if ( is_tax() ) {
    		$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    		$description = ! empty( $term->meta['description'] ) ? wp_kses_stripslashes( wp_kses_decode_entities( $term->meta['description'] ) ) : '';
    	}
    	if ( is_author() ) {
    		$user_description = get_the_author_meta( 'meta_description', (int) get_query_var( 'author' ) );
    		$description = $user_description ? $user_description : '';
    	}
    	if ( is_post_type_archive() && genesis_has_post_type_archive_support() ) {
    		$description = genesis_get_cpt_option( 'description' ) ? genesis_get_cpt_option( 'description' ) : '';
    	}
    	//* If there is no description specified, used the home description by default
         if ( empty( $description ) ) {
              $description = genesis_get_seo_option( 'home_description' ) ? genesis_get_seo_option( 'home_description' ) : get_bloginfo( 'description' );
         }
    	//* Add the description if one exists
    	if ( $description )
    		echo '<meta name="description" content="' . esc_attr( $description ) . '" />' . "\n";
    }
    

    It seems that maybe an option on the Genesis SEO Setting to use the home description as a fallback for any page without a customized description would be great.


    Matt Whiteley – WhiteleyDesigns, GitHub
    Designing, Developing & Creating with WordPress

    February 17, 2015 at 1:45 am #141078
    LeifQ
    Participant

    I use Yoast's plugin.
    https://yoast.com/wordpress/plugins/seo/#title-description

    WordPress SEO let’s you set templates for titles and meta descriptions for all types of pages, so you could come up with a template and not have to think about it, or you could use the WordPress SEO meta box to completely optimize your post title and meta description, using the snippet preview functionality to see what it would look like in Google

    February 17, 2015 at 7:22 am #141092
    WhiteleyDesigns
    Member

    Hey Leif,

    Thanks for the feedback. This is one of my go-to plug-ins for sure. I'd prefer to not use a plugin if possible, but you're right that this is the best solution currently.

    Matt


    Matt Whiteley – WhiteleyDesigns, GitHub
    Designing, Developing & Creating with WordPress

    February 18, 2015 at 3:15 pm #141245
    LeifQ
    Participant

    Same here. Yoast is part of a short list of plugins I install on every site.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 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