Write a function, and define it as a callback on the wp_head
hook:
<?php
/**
* print a alternate link on head for a several post
*
* @wp-hook wp_head
* @return void
*/
function wpse_162849_print_alternate_link() {
//don't do anything expect on singular pages
if ( ! is_singular() )
return;
// check the global post
if ( empty( $GLOBALS[ 'post' ] )
return;
// compare the post-ID
$your_post_ID = 42;
if ( $your_post_ID != $GLOBALS[ 'post' ]->ID )
return;
echo '<link rel="alternate" hreflang="en-gb" href="http://abc.com"/>';
}
add_action( 'wp_head', 'wpse_162849_print_alternate_link' );
Change the post ID to your needs. You can also implement another logic to choose the right post, for example by a special post meta.
Related Posts:
- How do you find the logo code on theme file or where can I find the header theme file?
- Why won’t wp_mail() let me set the From: header when plain old PHP mail() will?
- Admin bar and fixed header issue?
- How to remove rest api link: in http headers?
- disable wordpress canonical tag meta
- Disable h1 and h2 from rich text editor combobox
- Recommended location to set response headers?
- Custom endpoint and X-WP-TotalPages (headers)
- Getting “Cannot modify header information – headers already sent” error on wp-admin only whenever any plugin is activated
- Additional Option on Custom Header admin
- Putting content into header.php without using wp_head
- Setting Last Modified HTTP Header on static Home Page
- If Modified Since HTTP Header
- Image slider to display at the very top of home page
- Remove rel=shortlink from HTTP header
- Getting redirect to happen before header output
- Indenting (tabbing) WP_head
- Why I can’t add a script-code into theme-settings without 403-forbidden?
- Is it wrong to put header tags inside WordPress help tabs? [closed]
- Authenticate a user for current request
- Want to make header and footer CMS driven sothat Editors can modify its content from wordpress admin section
- Header: Include Date Published and Date Modified
- Page source contains an http item that makes page insecure; but in php files it’s written as https!
- Cleanup Body_Class
- Google Tag Manger – no-script Code Not Found
- How to remove main domain header title from after sub domain header title
- Remove all WordPress HTTP headers (not in-source embeds)
- WordPress 502 | Header Upstream send too big
- Creating dynamic header and footer files
- Strange 403 header response
- 404 or ugly page on IE, but Firefox, Chrome looks perfect
- Insert custom PHP head above in WP pages
- Changing header text from uppercase to normal [closed]
- My header not showing up [closed]
- How to Access Script Tags in Header
- Where are my js and css links in header?
- Why does WordPress allow inserting tags into posts?
- Problems accessing stylesheets/scripts loaded in WP header
- Rotate images in header based on date
- Why does WP load so many files in the head of source code? How do I optimize it?
- How to add some lines to the wp-login.php header via functions.php?
- Hook to change HTTP response headers
- allowed_http_origins() only works in theme functions.php
- Why are tags from the header showing up on my WordPress site? [closed]
- How to register and set http/2 server prefetch for a specific asset?
- Header with content
- WordPress Template not getting my Sub-Header File
- How to add social follow button to header? [closed]
- Include two headers
- Insert Facebook button into header [closed]
- Custom headers in WordPress, are there also custom footers?
- Point get_header() to different plugin
- How do I get the Social Media Plugin to show up in my Twenty Eleven child theme’s header?
- Adding more tabs to horizontal navigation bar
- Code needs wrapper/container to put footer back in, but where?
- Dynamic height in custom header image panel
- How can I remove or change the tooltip of an icon
- Design Header meta on single posts wordpress
- Including PHP files in header.php
- Remove server response header
- Using a nonce Content Security Policy header for style-src for inline style elements returns errors
- How can I use an iframe element as my header media?
- Easiest way to use relative URLs in my WordPress header
- Should I use do_action in the header file?
- Video Header in 2016 theme
- Enable CORS for getting an inline SVG by URL
- Warning: Cannot modify header information – headers already sent by
- Stop plugin from adding cache headers
- my dashboard does not have the option to fix the header or change the theme. how can i get that to show?
- How to prevent a style sheet to affect a header.php or footer.php?
- How do I change top header background color
- Why is http header providing 404 while site is online?
- only header is showing up in posts
- How do I apply different headers to different pages using this template?
- force download a file in template_redirect hook
- video header in desktop view, image header in mobile view
- Force download of MP3 file in Safari
- If is single in header.php [duplicate]
- Social icons on my index page don’t take visitor to specific site(s) [closed]
- show wordpress data without headers
- Override theme metadata in header
- Header Image instead of dynamic text
- Checking if certain header meta data is set
- setCookie before headers are sent?
- Download custom file in wordpress backend [duplicate]
- Change header based on visitor choice
- Inject code in the header of my template
- Random header image but also specific header for certain pages
- Dynamically changing header text depending on URL in WordPress html page
- After being hacked Fatal error: Call to undefined function get_header() in 404.php on line 1
- change headline of page
- wp_redirect() is not working
- How change the header color?
- How to remove lines over text using Phlox theme with Elementor Pro?
- My CSS, footer and header don’t show up!
- End of script output before headers – multiple apache error_log errors
- Editing Header with a Page Builder [closed]
- WordPress mobile and desktop header problems [closed]
- WordPress custom header parameter combine with cache
- How do you modify HTTP response headers on feed/?