• 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

Meta Description From Custom Field

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 › Meta Description From Custom Field

This topic is: not resolved

Tagged: custom, Eleven40, Meta Description

  • This topic has 5 replies, 2 voices, and was last updated 9 years, 11 months ago by rfmeier.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • June 25, 2013 at 11:35 pm #47750
    Vikram
    Member

    Hi there,

    I am using Eleven40 theme.

    I would like to for my site's meta tag (and not the post meta), display the summary from a custom field value.

    So, this should look like this:

    <meta name="description">Summary from Custom Field</meta>

    I know how to get the value from the custom field in my functions.php.

    BUt I can't seem to figure out how to add that value to the meta tag.

    Any help appreciated!

    June 26, 2013 at 7:02 pm #47917
    rfmeier
    Member

    Hello,

    You can start by checking out the source code for the 'genesis_meta' action in the genesis/lib/structure/header.php file. You can either remove the default action and add your own or use the '_genesis_description' custom meta field.

    I hope this points you in the right direction.


    Ryan Meier – Twitter

    June 27, 2013 at 4:25 pm #48118
    Vikram
    Member

    Thank you Ryan for pointing me in the right direction.

    This is the solution that I came up with:

    In the functions.php, I added a custom function:

    add_action('genesis_meta', 'custom_seo_description');
    function custom_seo_description() {
      if(is_singular('post')) {
        echo '<meta name="description" content="' . get_field('project_summary') . '" />';
      } else if(is_archive()) {
        echo '<meta name="description" content="' . category_description() . '" />';
      } else if(is_singular('competition')) {
        echo '<meta name="description" content="' . get_the_title() . '" />';
      }
    }
    June 27, 2013 at 5:36 pm #48128
    rfmeier
    Member

    Did that work okay for you?


    Ryan Meier – Twitter

    June 27, 2013 at 5:39 pm #48129
    Vikram
    Member

    Yes that solution works for me. Is there an issue with this solution that I can't see?

    Vikram

    June 27, 2013 at 5:42 pm #48131
    rfmeier
    Member

    None that I can see. I am glad it worked. Good luck.


    Ryan Meier – Twitter

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

© 2023 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