• Resolved boriskamp1991

    (@boriskamp1991)


    Hi guys! I can’t get the wpseo_title filter to work. i have the following code in my functions.php:

    
    add_filter('wpseo_title','custom_title');
    function custom_title( $title ){
      global $post;
      if (is_post_type_archive( 'locaties' )) {
    
        $title = get_field('locaties_top_content_group', 'option')['kop'];
    
      } else if (is_post_type_archive( 'merken' )) {
    
        $title = get_field('merken_top_content_group', 'option')['kop'];
    
      } else if (is_post_type_archive( 'nieuws' )) {
    
        $title = get_field('nieuws_top_content_group', 'option')['kop'];
    
      } else if (is_post_type_archive( 'kennisbank' )) {
    
        $title = get_field('kennisbank_top_content_group', 'option')['kop'];
    
      } else if (is_post_type_archive( 'vacatures' )) {
    
        $title = get_field('vacatures_top_content_group', 'option')['kop'];
    
      } else if (get_field('top_content_group', $post->ID)['kop'] || get_field('metadata_group', $post->ID)['meta_title']) {
    
        if (get_field('metadata_group', $post->ID)['meta_title']) {
          $title = get_field('metadata_group', $post->ID)['meta_title'];
        } else {
          $title = get_field('top_content_group', $post->ID)['kop'];
        }
    
      }
    
      return $title;
    }
    

    this should set the meta og:title in the head. However it always returns as page_title + - site_name so page1 - my blog for example.

    for the <title></title> in the head it does work though!

    What am I doing wrong here?
    Im building locally and have the yoast seo pluging installed alongside ACF, yoast duplicate post, svg support and force regenerate thumbnails, so that should’nt be the problem right?

    Thanks in advance!

    • This topic was modified 2 years, 9 months ago by boriskamp1991.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wpseo_title filter not working’ is closed to new replies.