genesis_seo_meta_description in post_meta

Community Forums Forums General Discussion genesis_seo_meta_description in post_meta

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  eddieb 1 year, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46103

    eddieb
    Participant
    Post count: 15

    I want to replace the contents of genesis_post_meta with the contents of genesis_seo_meta_description. I thought I could just add

    add_filter(‘genesis_post_info’, ‘genesis_seo_meta_description’);

    to custom_functions.php (I’m using Reactiv, a child theme from Themedy.com)

    But that didn’t work. As per this article, one option would be to replicate “function genesis_seo_meta_description()” (from /wp-content/themes/genesis/lib/structure/header.php) into my custom_functions.php, but there has to a more appropriate way to do this.

    I also tried adding

    function custom_post_info() {
    $post_info = genesis_seo_meta_description();
    return $post_info;
    }

    That also didn’t work.

    • This topic was modified 1 year, 6 months ago by  eddieb.
    • This topic was modified 1 year, 6 months ago by  eddieb.
    • This topic was modified 1 year, 6 months ago by  eddieb.
    • This topic was modified 1 year, 6 months ago by  eddieb.
    • This topic was modified 1 year, 6 months ago by  eddieb.
    • This topic was modified 1 year, 6 months ago by  eddieb.
    #46191

    rfmeier
    Participant
    Post count: 603

    Hello,

    The genesis_seo_meta_description() is an action callback. It will print out code instead of returning a string, so it will not work with a filter.

    Also, genesis_seo_meta_description returns a meta element for the head section of a page, so it would not render properly in the first place.

    [php]
    //* Add the description if one exists
    if ( $description )
    echo ‘<meta name="description" content="’ . esc_attr( $description ) . ‘" />’ . "\n";[/php]

    So if you want the meta description as post info, you could probably clone the function to return the description and use the new function as a filter callback for ‘genesis_post_info’.

    I hope this helps.


    #46247

    eddieb
    Participant
    Post count: 15

    i was trying to get the full meta line out of it first, then proceed to trim it via regex. easier than cloning the function. i will give it a try and report back.

     

    thanks!

    #46294

    eddieb
    Participant
    Post count: 15

    For reference, this worked:

    add_filter('genesis_post_info', 'custom_post_info');
    function custom_post_info() {
     if ( genesis_get_custom_field( '_genesis_description' ) )
     $description = genesis_get_custom_field( '_genesis_description' );
     return $description;
     }
    • This reply was modified 1 year, 6 months ago by  eddieb.
    • This reply was modified 1 year, 6 months ago by  eddieb.
    • This reply was modified 1 year, 6 months ago by  eddieb.
    • This reply was modified 1 year, 6 months ago by  eddieb.
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.