• Resolved hank3rd

    (@hank3rd)


    We use internal names for the WP title, so I am opting to use the Yoast SEO title as a custom title result. Most of our pages use the available variable for “Separator” and “Title. I only have this implemented in our staging environment so far after seeing that we do not want the WP title to show.

    This is causing issues with the result. It is showing as TITLE%%page%%%%sep%%%%sitename%%

    Is there a way to keep the SEO title, but exclude the variables or have them show right?

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi,

    It’s probably doable, but definitely needs some custom code to fetch the SEO titles. Based on their documentation, something like this may work:

    add_filter( 'asl_results', 'asl_get_seo_title', 10, 1 );
    function asl_get_seo_title( $results ) {
        foreach ($results as $k=>&$r) {
            // Get the seo title
            $seo_title = get_post_meta($r->id, '_yoast_wpseo_title', true);
            // Modify it
            if ($seo_title !== false && $seo_title != "")
                $r->title  = wpseo_replace_vars( $seo_title, get_post($r->id) );
        }
        return $results;
    }

    All the best,
    Ernest M.

    Thread Starter hank3rd

    (@hank3rd)

    This looks awesome and hope it will help. I am lookin to see where to add this. Just in case I cannot find it, would you be able to let me know?

    Plugin Author wpdreams

    (@wpdreams)

    Sure! Please check this knowledge base for the exact guidelines 🙂

    Thread Starter hank3rd

    (@hank3rd)

    Thank you! This worked beautifully!

    Plugin Author wpdreams

    (@wpdreams)

    Great to hear 🙂

    I will keep this snippet in case someone else needs it.

    Feel free to rate the plugin if you like it, it is greatly appreciated and helps us a lot! I will mark this as resolved now.

    All the best,
    Ernest

    Thread Starter hank3rd

    (@hank3rd)

    @wpdreams is seems that the script stopped working. Is there a way to find a fix?

    Thread Starter hank3rd

    (@hank3rd)

    I think that what is happening, is if any of the variables are being used it is using that instead of the text. If there are not variables, it is fine, but if it is set up like this, Contact our team today %%sep%% %%sitename%% it pulls in like that. I hope there is a resolve for this.

    Plugin Author wpdreams

    (@wpdreams)

    Hi,

    That sounds like an issue with the wpseo_replace_vars function from the WP Seo plugin, that is the one doing the replacement. The code only gets the SEO title and calls this function (on line 8) to do the replacement for the variables, then uses whatever the function is returning.

    You may have to ask the WP Seo support about this. I checked the documentation and there was no change in this function recently, it should work just like it worked before.

    All the best,
    Ernest

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Results using Yoast SEO Title’ is closed to new replies.