Hreflang tags are used to indicate to search engines the language and location of a webpage. You can add hreflang tags to specific pages in WordPress without using a plugin by following these steps:

  1. Identify the pages that you want to add hreflang tags to. You can do this by checking the URL of the pages or by inspecting the HTML source code.
  2. Determine the language and location of each page. You can use the <html> element’s lang attribute to indicate the language of the page, and the hreflang attribute to indicate the location of the page. For example:
<html lang="en-US" hreflang="en-US">
  1. Add the hreflang tags to the head section of the pages. You can do this by using the wp_head action hook:
function add_hreflang_tags() {
if ( is_page( 'page-slug' ) ) {
esc_url( get_permalink() )
add_action( 'wp_head', 'add_hreflang_tags' );

This code will add an hreflang tag to the head section of the page with the slug “page-slug”. You can customize the code to add hreflang tags to multiple pages by using the is_page() function or by checking the $post global variable.

(Visited 51 times, 1 visits today)
Was this article helpful?
Close Search Window