Answer the question
In order to leave comments, you need to log in
How to template meta tags for product pages and home page in Yoast SEO?
Colleagues, please tell me how to register separate meta tags for the main page of an online store in the Yoast SEO plugin (using woocoomerce). And how to make an automatic template of meta tags with product name support on product pages?
PS If I understood correctly, then in
SEO > Display in SERPs > Main page: SEO titleresponds to the meta tags of the main page.
Answer the question
In order to leave comments, you need to log in
You can create your own variables for yoast. Here are some examples:
function get_seo_instead_title() {
if ( is_single() ) {
if ( get_post_type() === 'route' ) {
$roads_subtype = get_post_meta(get_the_ID(), 'subtype', true );
if ( $roads_subtype == 'bus' ) {
return 'Расписание автобусов ' . get_the_title();
} else {
return 'Расписание маршрутов ' . get_the_title();
}
}
}
}
function get_seo_before_title() {
if ( is_tax() ) {
if ( is_tax( 'routes' ) ) {
return 'Справочник маршрутов города ';
}
}
}
function get_seo_after_title() {
if ( is_single() ) {
if ( get_post_type() === 'platform' ) {
return ' — маршруты и расписание транспорта';
}
}
}
// %%BeforeTitle%% %%title%% %%AfterTitle%%
// %%BeforeTitle%% %%term_title%% %%AfterTitle%%
// define the action for register yoast_variable replacments
function register_custom_yoast_variables() {
wpseo_register_var_replacement( '%%BeforeTitle%%', 'get_seo_before_title', 'advanced', 'Some before title text' );
wpseo_register_var_replacement( '%%AfterTitle%%', 'get_seo_after_title', 'advanced', 'Some after title text' );
wpseo_register_var_replacement( '%%InsteadTitle%%', 'get_seo_instead_title', 'advanced', 'Some instead title text' );
}
// Add action
add_action('wpseo_register_extra_replacements', 'register_custom_yoast_variables');
get_the_ID()
, get_the_title()
, get_post_meta()
etc. work. Common templates are in the adjacent tabs of the screenshot you are showing - Content Types and Taxonomies
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question