0

My WP site is running Genesis. I've just implemented my first custom page template in a child theme. The template runs some PHP and makes some data available to any page based on the template using shortcodes. All is working well, except...

For SEO, I'd like to set several items in the head section - most importantly the page title but also some meta items. I use the Yoast Wordpress SEO and this section is top/tailed with a Yoast comment so perhaps it's taken charge of these fields.

Are there any filters I can use (perhaps with a higher priority than Yoast uses) to set selected head items?

1 Answer 1

1

Yoast Support kindly provided me with the following reference:

https://yoast.com/wordpress/plugins/seo/api/

Using the following filters calling my own functions, I was able to change everything in the header based on dynamic content.

add_filter('wpseo_title', 'setPageTitle', 10);
add_filter('wpseo_metadesc', 'setMetaDesc', 10);
add_filter('wpseo_canonical', 'setCanonical', 10);
add_filter('wpseo_opengraph_image', 'setOG_Image', 10);
add_filter('the_title', 'setTitle', 10);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.