Community Forums › Forums › Archived Forums › General Discussion › Accessing 'Custom Document Title' field from Genesis theme
Tagged: seo, title, WooCommerce
- This topic has 3 replies, 2 voices, and was last updated 10 years, 1 month ago by krystyn.
-
AuthorPosts
-
March 2, 2014 at 8:04 pm #93115kaplunkiigirlMember
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://localMarch 2, 2014 at 8:10 pm #93117kaplunkiigirlMemberI 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.
March 2, 2014 at 8:45 pm #93121kaplunkiigirlMemberOk, 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.
March 18, 2014 at 9:31 am #95495krystynParticipantI 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"></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.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.