Wednesday, 20 February 2019

How To: Include Custom Fields in Post Titles & Descriptions in Yoast Automatically


Following on the previous post about adding a location and a date to the post URL automatically, we’re going to be looking at adding custom fields in post titles and descriptions. The sort you can see in Yoast Snippets. This will saving us time in optimising the post. We are using Yoast WordPress SEO to build this feature. The reason being is that Yoast has a range of filters and functions that you can take advantage of this for your future projects. In my opinion as a former SEO, the strength of WordPress SEO over it’s competitors is not in it’s ability to do the basic stuff well, but the way in which you can automate SEO to a degree using custom code. In this example, we’ll be using a filter and a function to build new features.
The wpseo_register_extra_replacements action
The wpseo_register_extra_filter action is an action that allows you to register extra variable replacements. Variables in Yoast usually take the place of a keyword surrounded by four percentage signs – for example the %%title%% string is replaced with the title string. We will need to add a function to the action to register the variable replacement.
The wpseo_register_var_replacement
Source: https://managewp.org/articles/18386/how-to-include-custom-fields-in-post-titles-descriptions-in-yoast-automatically



source https://williechiu40.wordpress.com/2019/02/20/how-to-include-custom-fields-in-post-titles-descriptions-in-yoast-automatically/

No comments:

Post a Comment