Want to gain more control of your SEO Titles and Descriptions? This can be easily done by taking advantage of WordPress SEO’s actions and filters.

Examples:

Customize Title

Add some custom text to all SEO Titles for the ‘project’ post type by using the wpseo_title filter.

add_filter('wpseo_title', 'custom_seo_title_function');
function custom_seo_title_function($title) {
    global $post;
    if(  get_post_type( $post->ID ) == 'slug_post_type' ) {
        $author_id = $post->post_author;
        $author = get_the_author_meta('user_nicename',$author_id);
        $title = $title.' by '.$author; 
    }
    return $title;
}

 

Customize Description

Add custom text to SEO Description for ‘project’ post type by using the wpseo_metadesc filter.

add_filter('wpseo_title', 'custom_seo_desc_function');
function custom_seo_desc_function($description){
  global $post;
  if( get_post_type($post->ID) == 'slug_post_type' ) {
    global $post;
    $author_id = $post->post_author;
    $description = $description. ' ' .get_the_author_meta('description',$author_id);
  }
  return $description;
}

 

Want to learn more?

Visit the link below to learn how to customize even more:

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

Ready to get started?

Get in touch, or signup for a service.