The get_index_rel_link() WordPress PHP function retrieves the site index relational link.
Usage
echo get_index_rel_link();
Parameters
This function has no parameters.
More information
See WordPress Developer Resources: get_index_rel_link
Examples
Display index relational link in the head section of your theme
In this example, we’ll display the index relational link in the head section of your WordPress theme.
function add_index_rel_link_to_head() { echo get_index_rel_link(); } add_action('wp_head', 'add_index_rel_link_to_head');
Add index relational link to the RSS feed
In this example, we add the index relational link to the RSS feed of your site.
function add_index_rel_link_to_feed() { echo get_index_rel_link(); } add_action('rss2_head', 'add_index_rel_link_to_feed');
Add index relational link to a custom function
In this example, we create a custom function that outputs the index relational link along with other metadata.
function output_metadata() { echo get_index_rel_link(); // Output other metadata... }
Add index relational link to a custom hook
In this example, we create a custom hook and add the index relational link to it.
function custom_hook() { do_action('custom_hook_action'); } function add_index_rel_link_to_custom_hook() { echo get_index_rel_link(); } add_action('custom_hook_action', 'add_index_rel_link_to_custom_hook');
Conditionally display index relational link
In this example, we display the index relational link only on the homepage.
function add_index_rel_link_on_homepage() { if (is_home()) { echo get_index_rel_link(); } } add_action('wp_head', 'add_index_rel_link_on_homepage');