Support

Account

Forum Replies Created

  • Excellent – worked almost straight out of the box – thanks a million. For anyone else who needs it, my final code was;

    
    function change_seo_title($string) {
      $queried_object = get_queried_object();
      if ( !isset($queried_object->ID) || get_post_type($queried_object->ID) != 'post' ) {
        // bail early
        return $string;
      }
      $related_post = get_field('product', $queried_object->ID);
      if ($related_post) {
        $related_post_title = get_the_title($related_post->ID);
        $new_title = $related_post_title . " - " . $string;
      }
      return $new_title;
    }
    add_filter('wpseo_title', 'change_seo_title');
    
  • Following on from this, I have a Post Object as my custom field that I want to retrieve the title from. Using cf_field_name will only return the ID of that Post Object – what do I have to do to lookup that post and add the title from that post as a custom field which is available to Yoast?

    Any ideas?

    Thanks,

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