Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Yoast title field
This topic contains 6 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year, 7 months ago.
- AuthorPosts
- August 6, 2021 at 11:52 am #34194
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
August 6, 2021 at 11:55 am #34195Adding 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.August 6, 2021 at 12:52 pm #34200Hi,
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 :)
August 6, 2021 at 1:23 pm #34201We 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?
August 6, 2021 at 3:11 pm #34210Well, 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 :)
August 6, 2021 at 3:59 pm #34211This 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, 7 months ago by
thewebco76.
August 7, 2021 at 8:55 am #34213You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
-
This reply was modified 1 year, 7 months ago by
- AuthorPosts
You must be logged in to reply to this topic.