Yoast title field

This topic contains 6 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 year, 1 month ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #34194
    thewebco76
    thewebco76
    Participant

    I have a client using the paid version, and I was wondering – We’re using yoast field as title.

    however, that of course includes yoast snippet variables for example – %%sitename%%

    Anyway to exclude things like that?

    See here for more :

    https://yoast.com/help/list-available-snippet-variables-yoast-seo/

    Ideally – ( and I’m not sure when yoast fires ) – these fields could be rendered by delay so that they actually show the generated yoast field ( that may be too late to fire – I’m not familiar with yoast enough but figure you may be)

    Thanks

    #34195
    thewebco76
    thewebco76
    Participant

    Adding screenshot so you can see

    No ftp / admin access needed at this point but can get it if the question can’t be answered simply.

    Attachments:
    You must be logged in to view attached files.
    #34200
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    The plugin requests the result titles from WordPress (via get_the_title) – and those should be rendered already, meaning all the hooks, filters, modifiacations and anything else should be done on them by the time of the request.
    We are also using Yoast on one of our test servers, but the titles are rendered just fine, so I am not sure what exactly is going on here.

    Can you please check if the custom ajax handler option is disabled. When enabled, I can imagine there is a delay on the yoast plugin loading.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #34201
    thewebco76
    thewebco76
    Participant

    We are not using the title; rather customer field for the title. ( they use page titles internally on private site )

    So I assigned _yoast_wpseo_title as primary title field.

    But I am now seeing in your documentation that it looks like you only support this field if they are typed in. ( not auto generated)

    Is there a workaround for this – where I can use the yoast seo field and have the results fire after they is rendered?

    #34210
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Well, I am not sure then, but maybe via a custom code.

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_filter( 'asp_results', 'asp_force_yoast_title', 10, 1 );
    function asp_force_yoast_title( $results ) {
    	foreach ($results as $k => &$r ) {
    		$r->title = apply_filters('the_title', $r->id);
    	}
    	return $results;
    }

    If all goes well, this should force the title hook again on the final search results, resolving the yoast syntax.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #34211
    thewebco76
    thewebco76
    Participant

    This only replaced the title with the ID (you have $r->id in the filter)

    But this pointed me to something useful – so thanks! Shared in case you ever need it for anyone else :

    add_filter( 'asp_results', 'asp_force_yoast_title', 10, 1 );
    function asp_force_yoast_title( $results ) {
    	foreach ($results as $k => &$r ) {
    		
    		$r->title = apply_filters('the_title', $r->title);
    		$newtitle = 'My Site Name Replacement';
    		$realtitle = get_the_title($r->id);
    		$r->title = str_replace( array("%%sitename%%","%%sep%%","%%title%%","%%page%%"), array($newtitle, " | ", $realtitle,""), "$r->title" );
    		
    	}
    	
    	return $results;
    }
    • This reply was modified 1 year, 1 month ago by thewebco76 thewebco76.
    #34213
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


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

You must be logged in to reply to this topic.