Skip to content

Instantly share code, notes, and snippets.

@freddielore
Last active August 18, 2019 04:52
Show Gist options
  • Select an option

  • Save freddielore/fbf3e3311c33143d74ea47f9ad3b59b8 to your computer and use it in GitHub Desktop.

Select an option

Save freddielore/fbf3e3311c33143d74ea47f9ad3b59b8 to your computer and use it in GitHub Desktop.

Revisions

  1. freddielore revised this gist Aug 18, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ function demo_export_default_seo_titles_v2( $title, $post ){
    if( class_exists('WPSEO_Option' ) && empty($title) ){
    $settings = get_option( 'wpseo_titles' );
    $replacer = new WPSEO_Replace_Vars();
    $title = $replacer->replace( $settings['title-' . $post->post_type], array() );
    $title = $replacer->replace( $settings['title-' . $post->post_type], $post );
    }

    return $title;
  2. freddielore created this gist Aug 18, 2019.
    14 changes: 14 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <?php
    add_filter( 'smart_seo_export_title', 'demo_export_default_seo_titles_v2', 8, 2 );
    function demo_export_default_seo_titles_v2( $title, $post ){

    // if no custom SEO title being defined, get global defaults for Yoast
    if( class_exists('WPSEO_Option' ) && empty($title) ){
    $settings = get_option( 'wpseo_titles' );
    $replacer = new WPSEO_Replace_Vars();
    $title = $replacer->replace( $settings['title-' . $post->post_type], array() );
    }

    return $title;
    }
    ?>