Support

Account

Home Forums Backend Issues (wp-admin) ACF with custom Titles & Yoast SEO Reply To: ACF with custom Titles & Yoast SEO

  • @lucpestille for that I think you would need to use the SEO hook for modifying the post title, but you’ll need to do a bit more checking

    
    add_filter('wpseo_title', 'change_seo_title');
    function change_seo_title($string) {
      $queried_object = get_queried_object();
      if (!isset($queried_object->ID || 
          get_post_type($queried_object->ID) != 'your-post-type-here')) {
        // bail early
        return $string;
      }
      $related_post = get_field('post_object_field_name', $queried_object->ID);
      if ($related_post) {
        $title = get_the_title($related_post->ID);
        $string .= ' - '.$title;
      }
      return $title;
    }