In WordPress, permalink_anchor()prints a small anchor tag with an ID for the current post. The anchor is empty, so it shows nothing on the page. It only marks a spot.
You can then link to that spot with a jump link, such as #post-42. It is helpful on pages that show many posts, like archives. Use it inside the Loop.
Syntax
Call it at the top of each post in the Loop.
WordPress
<?php permalink_anchor(); ?>
Call
What it does
permalink_anchor()
Print an anchor with the ID post-42.
permalink_anchor( 'id' )
The same as the default.
permalink_anchor( 'title' )
Print an anchor made from the post title and ID.
It prints the anchor. It works on the current post, so use it in the Loop.
Full declaration
WordPress
permalink_anchor( string $mode = 'id' ): void
Parameters
Parameter
Description
$mode
string. id (default) makes an ID such as post-42. title makes an ID from the post title, such as hello-world-42.
Return Value
Return Value
Description
void
Nothing is returned. An anchor tag is printed.
WordPress Examples
Three short examples. Each one shows the code and what it prints or does.