Headings as link targets Edit

Highlight: Use heading anchors.

Heading anchors are useful for document sections that are frequently linked to. To make headings into link targets, add an anchor. To avoid breaking existing heading links in published content, create an anchor that uses the same ID string as the published page. You can also create a custom anchor for a heading; for example, you can create a short anchor for a long heading. A custom anchor decreases the possibility of breaking existing links if the heading text changes.

Adding an anchor

Note: For content published on wordpress.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org/, WordPress may automatically create a link target for headings by default. For more information about creating heading anchors on WordPress, see Page jumps.

{% codetabs %}
{% HTML %}
To add an anchor to a heading in HTML, do the following:

  • Add a <section> element with an id attribute. Don’t use <a name>.
  • Use lowercase for id values.
  • Insert hyphens between words.

Examples

Not recommended:

<br />
&lt;h2>&lt;a name=&quot;Determining_Plugin_And_Content_Directories&quot;>Determining plugin and content directories&lt;/a>&lt;/h2><br />


Not recommended:

[code lang=htmlHTML HTML is an acronym for Hyper Text Markup Language. It is a markup language that is used in the development of web pages and websites.]
<a name="Determining_Plugin_And_Content_Directories"></a>
<h2>Determining pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party and content directories</h2>
“`


**Acceptable:**
“`htmlHTML HTML is an acronym for Hyper Text Markup Language. It is a markup language that is used in the development of web pages and websites.
<h2 id="determining-pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party-and-content-directories">Determining plugin and content directories</h2>
[/code]


Recommended:

<br />
&lt;section id=&quot;determining-plugin-and-content-directories&quot;><br />
&lt;h2>Determining plugin and content directories&lt;/h2><br />
&#8230;<br />
&lt;/section><br />


{% Markdown %}
To add an anchor to a heading in Markdown, do the following:
– Add {:#ID_OF_ANCHOR} after the heading, to the end of the line that the heading is on. Replace ID_OF_ANCHOR with the ID for this heading.
– Use lowercase for id values.
– Insert hyphens between words.

Examples

Not recommended:


## Determining pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party and content directories {: id="ID_OF_ANCHOR" }


Not recommended: (Note single quotation marks)


## Determining pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party and content directories {: id='ID_OF_ANCHOR' }


Not recommended:


## Determining pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party and content directories
{:#ID_OF_ANCHOR}


Acceptable:


## Determining pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party and content directories {: id="determining-directories" }


Recommended:


## Determining pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party and content directories {:#determining-plugin-and-content-directories}


Recommended:


## Determining pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party and content directories {:#determining-plugin-content-directories}


{% end %}

Top ↑

Changing an anchor

Note: For content published on wordpress.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org/, WordPress may automatically create a link target for headings by default. For more information about creating heading anchors on WordPress, see Page jumps.

To change an anchor, you need to create a custom anchor that uses the older ID string. A custom anchor decreases the possibility of breaking existing links if the heading text changes. You can find the ID string by inspecting the heading.

{% codetabs %}
{% HTML %}

If you change a heading from Custom template files to Custom post type template files, then add a custom anchor that uses the older ID string and formatting.

Example

Recommended:

<br />
&lt;section id=&quot;custom_template_files&quot;><br />
&lt;h2>Custom post type template files&lt;/h2><br />
&#8230;<br />
&lt;/section><br />


{% Markdown %}

If you change a heading from Custom template files to Custom post type template files, then add a custom anchor that uses the older ID string and formatting.

Example

Recommended:


## Custom post typeCustom Post Type WordPress can hold and display many different types of content. A single item of such a content is generally called a post, although post is also a specific post type. Custom Post Types gives your site the ability to have templated posts, to simplify the concept. template files {:#custom_template_files}


{% end %}

Last updated: