Advanced SEO Title Management and Customization¶
- Table of contents
- Advanced SEO Title Management and Customization
NOTICE: This feature works as expected. This documentation needs some more work. Please let me know if any part of it is confusing.
Since version 2.9.2 Add-Meta-Tags supports advanced title management and customization. The plugin is now able to handle title generation on its own and use user-defined templates in order to generate custom titles. The custom titles affect the following title types:
- The titles that appear in the
title
HTML element. - The titles that appear in the metadata.
There are different sets of templates for each of the above title types. Also, there are some template variables available to the user for quick title template editing.
Read more about:
Theme Requirements¶
The theme requirements for this feature to work as expected are outlined in the Requirements page.
Template Variables¶
Although it is possible to use the WordPress API in order to get the information you need and set the title template dynamically on every request, there are some template variables that can be used in the title templates in order to avoid the need to use the WordPress API directly.
The available template variables are the following:
Date related template variables¶
If a date archive has been requested, these are expanded to the relevant date elements. Alternatively, if a post, page, attachment or custom post type has been requested, these are expanded to the date elements of the post's publication date.
#year#
- Expanded to the 4-digit year.#month#
- Expanded to the month number.#month_name#
- Expanded to the month name (based on current locale).#day#
- Expanded to the current day number within the current month.
Site related template variables¶
#site_name#
- Expanded to the web site name as set in the general settings of your WordPress web site.#site_tagline#
- Expanded to the tagline as set in the general settings of your WordPress web site.
Pagination related template variables¶
#page#
- Expanded to the current page number either of an archive or of a multi-page post.#page_total#
- Expanded to the total number of pages of an archive or of a multi-page post.
Object title variable¶
#entity_title#
- This variable is expanded to the name of the requested object.#Entity_title#
- Same as#entity_title#
but with the first character converted to upper case.#Entity_Title#
- Same as#entity_title#
but with the first character of each word converted to upper case.
Below are the values #entity_title#
gets for the various parts of the WordPress web site:
- Default front page with the latest posts:
#entity_title#
is expanded to the web site's name (same as the #site_name# variable) - Front page using a static page:
#entity_title#
is expanded to the title of the static page. - The latest posts page using a static page:
#entity_title#
is expanded to the title of the static page. - Yearly archive:
#entity_title#
is expanded to the 4-digit year of the archive. (same as the #year# variable) - Monthly archive:
#entity_title#
is expanded to the name of the month of the archive. (same as the #month_name# variable) - Daily archive:
#entity_title#
is expanded to the number of the day of the archive. (same as the #day# variable) - Taxonomy archive:
#entity_title#
is expanded to the name of the requested term. - Author archive:
#entity_title#
is expanded to the name of the author. - Custom post type archive:
#entity_title#
is expanded to the name of the custom post type. - Content (posts, pages, attachments, custom post types):
#entity_title#
is expanded to the title of the post.
Template naming conventions¶
TODO: Clean up the following info.
Template names:
- Template names ending with
_paged
are used when the requested page of the archive or of the multipage content post is >=2. - Taxonomy archives:
archive_taxonomy_TAXONOMYSLUG
(Note: supports_paged
) - Attachment page template:
content_attachment
(Note: does not support_paged
) - Attachment page with media type:
content_attachment_MEDIATYPE
(eg,content_attachment_image
) (Note:does not support_paged
) - Post or custom post type:
content_POSTTYPE
(Note: supports_paged
) - Post or custom post type with post formats:
content_POSTTYPE_POSTFORMAT
(Note: supports_paged
)
Default templates for the title
HTML Element¶
// Default front page displaying the latest posts
'front_page_default' => '#site_name# | #site_tagline#',
'front_page_default_paged' => '#site_name# | Page #page# | #site_tagline#',
// Front page using static page
'front_page_static' => '#site_name# | #site_tagline#',
//'front_page_static' => '#entity_title# | #site_tagline#',
'front_page_static_paged' => '#site_name# | Page #page# | #site_tagline#',
// Latest posts page using static page
'blog_index_static' => '#entity_title# | #site_name#',
'blog_index_static_paged' => '#entity_title# | Page #page# | #site_name#',
// Date Archives
// Date::Yearly
'archive_date_yearly' => 'Yearly Archive: #year# | #site_name#',
'archive_date_yearly_paged' => 'Yearly Archive: #year# | Page #page# | #site_name#',
// Date::Monthly
'archive_date_monthly' => 'Monthly Archive: #month_name# #year# | #site_name#',
'archive_date_monthly_paged'=> 'Monthly Archive: #month_name# #year# | Page #page# | #site_name#',
// Date::Daily
'archive_date_daily' => 'Daily Archive: #month_name# #day#, #year# | #site_name#',
'archive_date_daily_paged'=> 'Daily Archive: #month_name# #day#, #year# | Page #page# | #site_name#',
// Taxonomy Archives
// Taxonomy::Category
'archive_taxonomy_category' => '#Entity_title# Archive | #site_name#',
'archive_taxonomy_category_paged' => '#Entity_title# Archive | Page #page# | #site_name#',
// Taxonomy::Tag
'archive_taxonomy_post_tag' => '#Entity_title# Archive | #site_name#',
'archive_taxonomy_post_tag_paged' => '#Entity_title# Archive | Page #page# | #site_name#',
// Taxonomy::Custom
'archive_taxonomy_CUSTOMSLUG' => '#entity_title# Archive| #site_name#',
'archive_taxonomy_CUSTOMSLUG_paged' => '#entity_title# Archive | Page #page# | #site_name#',
// Author Archives
'archive_author' => '#entity_title# profile | #site_name#',
'archive_author_paged' => 'Content published by #entity_title# | Page #page# | #site_name#',
// Custom Post Type Archives
'archive_posttype_POSTTYPESLUG' => '#entity_title# Archive | #site_name#',
'archive_posttype_POSTTYPESLUG_paged' => '#entity_title# Archive | Page #page# | #site_name#',
// Content
// Content::Attachment
'content_attachment' => '#entity_title# | #site_name#',
//'content_attachment_image' => 'Image: #entity_title# | #site_name#',
//'content_attachment_video' => 'Video: #entity_title# | #site_name#',
//'content_attachment_audio' => 'Audio: #entity_title# | #site_name#',
// Content::Page
'content_page' => '#entity_title# | #site_name#',
'content_page_paged' => '#entity_title# | Page #page# | #site_name#',
// Content::Post
'content_post' => '#entity_title# | #site_name#',
'content_post_paged' => '#entity_title# | Page #page# | #site_name#',
// Post with format
//'content_post_image' => 'Image: #entity_title# | #site_name#',
//'content_post_video' => 'Video: #entity_title# | #site_name#',
//'content_post_audio' => 'Audio: #entity_title# | #site_name#',
//'content_post_status' => 'Status: #entity_title# | #site_name#',
//'content_post_gallery' => 'Gallery: #entity_title# | #site_name#',
//'content_post_link' => 'Link: #entity_title# | #site_name#',
//'content_post_quote' => 'Quote: #entity_title# | #site_name#',
//'content_post_chat' => 'Chat: #entity_title# | #site_name#',
// Content::Custom-Post-Type
'content_POSTTYPESLUG' => '#entity_title# | #site_name#',
'content_POSTTYPESLUG_paged' => '#entity_title# | Page #page# | #site_name#',
// is_error - TODO
// is_search - TODO
Default templates for the titles within the metadata¶
// Default front page displaying the latest posts
'front_page_default' => '#site_name#',
'front_page_default_paged' => '#site_name# | Page #page#',
// Front page using static page
'front_page_static' => '#site_name#',
'front_page_static_paged' => '#site_name# | Page #page#',
// Latest posts page using static page
'blog_index_static' => '#entity_title#',
'blog_index_static_paged' => '#entity_title# | Page #page#',
// Date Archives
// Date::Yearly
//'archive_date_yearly' => 'Yearly Archive: #year#',
//'archive_date_yearly_paged' => 'Yearly Archive: #year# | Page #page#',
// Date::Monthly
//'archive_date_monthly' => 'Monthly Archive: #month_name# #year#',
//'archive_date_monthly_paged'=> 'Monthly Archive: #month_name# #year# | Page #page#',
// Date::Daily
//'archive_date_daily' => 'Daily Archive: #month_name# #day#, #year#',
//'archive_date_daily_paged' => 'Daily Archive: #month_name# #day#, #year# | Page #page#',
// Taxonomy Archives
// Taxonomy::Category
'archive_taxonomy_category' => '#Entity_title# Archive',
'archive_taxonomy_category_paged' => '#Entity_title# Archive | Page #page#',
// Taxonomy::Tag
'archive_taxonomy_post_tag' => '#Entity_title# Archive',
'archive_taxonomy_post_tag_paged' => '#Entity_title# Archive | Page #page#',
// Taxonomy::Custom
'archive_taxonomy_CUSTOMSLUG' => '#entity_title# Archive',
'archive_taxonomy_CUSTOMSLUG_paged' => '#entity_title# Archive | Page #page#',
// Author Archives
'archive_author' => '#entity_title# profile',
'archive_author_paged' => 'Content published by #entity_title# | Page #page#',
// Custom Post Type Archives
'archive_posttype_POSTTYPESLUG' => '#entity_title# Archive',
'archive_posttype_POSTTYPESLUG_paged' => '#entity_title# Archive | Page #page#',
// Content
// Content::Attachment
'content_attachment' => '#entity_title#',
//'content_attachment_image' => '#entity_title#',
//'content_attachment_video' => '#entity_title#',
//'content_attachment_audio' => '#entity_title#',
// Content::Page
'content_page' => '#entity_title#',
'content_page_paged' => '#entity_title# | Page #page#',
// Content::Post
'content_post' => '#entity_title#',
'content_post_paged' => '#entity_title# | Page #page#',
// Post with format
//'content_post_image' => 'Image: #entity_title#',
//'content_post_video' => 'Video: #entity_title#',
//'content_post_audio' => 'Audio: #entity_title#',
//'content_post_status' => 'Status: #entity_title#',
//'content_post_gallery' => 'Gallery: #entity_title#',
//'content_post_link' => 'Link: #entity_title#',
//'content_post_quote' => 'Quote: #entity_title#',
//'content_post_chat' => 'Chat: #entity_title#',
// Content::Custom-Post-Type
'content_POSTTYPESLUG' => '#entity_title#',
'content_POSTTYPESLUG_paged' => '#entity_title# | Page #page#',
// is_error - TODO
// is_search - TODO
How to customize the templates¶
Available filter hooks¶
The title templates can be customized by attaching filtering functions to the following filter hooks:
amt_titles_title_element_templates
: for the title templates that are used for the content of thetitle
HTML element.amt_titles_metadata_title_templates
: for the title templates that are used for titles within the metadata.
read more information about the title templates related filter hooks.
Examples¶
function amt_titles_custom_title_element_templates($templates) {
$templates['content_post'] = 'ZZZ #entity_title# | #site_name#';
$templates['content_my_custom_post_type'] = 'YYY #entity_title# | #site_name#';
$templates['content_my_custom_post_type_paged'] = 'YYY #entity_title# | Page #page# | #site_name#';
return $templates;
}
add_filter('amt_titles_title_element_templates', 'amt_titles_custom_title_element_templates');
function amt_titles_custom_metadata_title_templates($templates) {
$templates['content_post'] = 'ZZZ #entity_title#';
$templates['content_my_custom_post_type'] = 'YYY #entity_title#';
$templates['content_my_custom_post_type_paged'] = 'YYY #entity_title# | Page #page#';
return $templates;
}
add_filter('amt_titles_metadata_title_templates', 'amt_titles_custom_metadata_title_templates');
Examples of commonly needed customizations¶
Please note that these are sample templates aimed to get you started with title customization.
WooCommerce¶
Example about how to customize the titles of WooCommerce pages:
// Title templates for the title element
function amt_titles_custom_title_element_templates($templates) {
$templates['archive_taxonomy_product_cat'] = 'Product Category: #entity_title# | #site_name#';
$templates['archive_taxonomy_product_cat_paged'] = 'Product Category: #entity_title# | Page #page# | #site_name#';
$templates['archive_taxonomy_product_tag'] = 'Product Tag: #entity_title# | #site_name#';
$templates['archive_taxonomy_product_tag_paged'] = 'Product Tag: #entity_title# | Page #page# | #site_name#';
$templates['content_product'] = 'Product: #entity_title# | #site_name#';
return $templates;
}
add_filter('amt_titles_title_element_templates', 'amt_titles_custom_title_element_templates');
// Title templates for the metadata
function amt_titles_custom_metadata_title_templates($templates) {
$templates['archive_taxonomy_product_cat'] = 'Product Category: #entity_title#';
$templates['archive_taxonomy_product_cat_paged'] = 'Product Category: #entity_title# | Page #page#';
$templates['archive_taxonomy_product_tag'] = 'Product Tag: #entity_title#';
$templates['archive_taxonomy_product_tag_paged'] = 'Product Tag: #entity_title# | Page #page#';
$templates['content_product'] = 'Product: #entity_title#';
return $templates;
}
add_filter('amt_titles_metadata_title_templates', 'amt_titles_custom_metadata_title_templates');
Easy-Digital-Downloads¶
Example about how to customize the titles of Easy-Digital-Downloads (EDD) pages:
// Title templates for the title element
function amt_titles_custom_title_element_templates_for_edd($templates) {
$templates['archive_taxonomy_download_category'] = 'Product Category: #entity_title# | #site_name#';
$templates['archive_taxonomy_download_category_paged'] = 'Product Category: #entity_title# | Page #page# | #site_name#';
$templates['archive_taxonomy_download_tag'] = 'Product Tag: #entity_title# | #site_name#';
$templates['archive_taxonomy_download_tag_paged'] = 'Product Tag: #entity_title# | Page #page# | #site_name#';
$templates['content_download'] = 'Product: #entity_title# | #site_name#';
$templates['content_download_paged'] = 'Product: #entity_title# | Page #page# | #site_name#';
return $templates;
}
add_filter('amt_titles_title_element_templates', 'amt_titles_custom_title_element_templates_for_edd');
// Title templates for the metadata
function amt_titles_custom_metadata_title_templates_for_edd($templates) {
$templates['archive_taxonomy_download_category'] = 'Product Category: #entity_title#';
$templates['archive_taxonomy_download_category_paged'] = 'Product Category: #entity_title# | Page #page#';
$templates['archive_taxonomy_download_tag'] = 'Product Tag: #entity_title#';
$templates['archive_taxonomy_download_tag_paged'] = 'Product Tag: #entity_title# | Page #page#';
$templates['content_download'] = 'Product: #entity_title#';
$templates['content_download_paged'] = 'Product: #entity_title# | Page #page#';
return $templates;
}
add_filter('amt_titles_metadata_title_templates', 'amt_titles_custom_metadata_title_templates_for_edd');