Accessing 'Custom Document Title' field from Genesis theme

Community Forums Forums General Discussion Accessing 'Custom Document Title' field from Genesis theme

This topic is: not resolved

Tagged: , ,

This topic contains 3 replies, has 2 voices, and was last updated by  krystyn 5 months, 2 weeks ago.

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

    kaplunkiigirl
    Participant
    Post count: 4

    I’m using Genesis with Dynamik Website Builder and WooCommerce.

    I have created a function in my custom functions.php file to modify the meta page titles in the shop (WooCommerce has its own function to set the titles, which overrides the Genesis function and I wasn’t happy with it).

    I would like to check whether a product category archive has a ‘Custom Document Title’ in the Genesis SEO settings for that archive and use that preferentially if it is set. Otherwise, I will use my standard function to set the title.

    I don’t know how to reference the value stored by the Genesis framework in the SEO settings for the (product) category.

    This is a cut-down version of my function to demonstrate the value I am trying to figure out how to access, represented by $genesis_seo_title

    
    add_filter( 'wp_title', 'yw_modify_page_titles', 20 );
    function yw_modify_page_titles( $title ) {
       if ( is_product_category() ){
          if( $product_category )
             if( $genesis_seo_title )
                return $genesis_seo_title;
             else
                return '<title>' . $product_category . ' | ' . 'Shop' . ' | ' . get_bloginfo('name') . '</title>'; 
       }
    }
    

    Can someone tell me what the syntax is that I need to use to access the value of the ‘Custom Document Title’ within the Genesis framework fields for a given category?

    $genesis_seo_title = ?? ($category_name);

    Thank you,

    Nikki

    http://local
    #93117

    kaplunkiigirl
    Participant
    Post count: 4

    I can see that in the ‘cpt-archive-settings.php’ file in the Genesis theme, that the value for this field is accessed via:

    $this->get_field_value( 'doctitle' )

    but I can’t get my head around how to access this value from outside the context of the object (ie in my custom functions.php file).

    Any pointers would be greatly appreciated.

    #93121

    kaplunkiigirl
    Participant
    Post count: 4

    Ok, so I now have an answer to this.

    In the Genesis lib/structure/header.php file

    Custom post type archives:

    if ( is_post_type_archive() && genesis_has_post_type_archive_support() ) {
    $title = genesis_get_cpt_option( 'doctitle' ) ? genesis_get_cpt_option( 'doctitle' ) : $title;
    }

    Categories:

    if ( is_category() ) {
    $term = $wp_query->get_queried_object();
    $title = ! empty( $term->meta['doctitle'] ) ? $term->meta['doctitle'] : $title;
    }

    So in the context of my product category, I needed this:

       global $wp_query;
       $term = $wp_query->get_queried_object();
       $product_category_seo_title = $term->meta['doctitle'];

    to give me access to the ‘Custom Document Title’ value for that category.

    #95495

    krystyn
    Participant
    Post count: 148

    @kaplunkiigirl

    I think I want to do the same thing. I have a category page, and on that category page, instead of using the post title , I’d like to use the Custom Document Title displaying on the image.

    This is what I’m using:

    add_action( ‘genesis_entry_header’, ‘beautiful_category_grid’);
    function beautiful_category_grid() {

    if ( $image = genesis_get_image( ‘format=url&size=portfolio’ ) ) {
    printf( ‘<div class=”pcategory-featured-image”>%s</div>’, get_permalink(), $image, the_title_attribute( ‘echo=0′ ) );

    }

    }

    Any hints as to how to swap that out so I can use the SEO title? I’m a little confused as to where you used your code.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.