Using WordPress ‘make_url_footnote()’ PHP function

The make_url_footnote() WordPress PHP function searches for all links in a given content, strips them out, and places them at the bottom of the content with numbers.


$content_with_footnotes = make_url_footnote($content);


  • $content (string) – Required. Content to process and extract links from.

More information

See WordPress Developer Resources: make_url_footnote


Basic usage

Convert links within a blog post content into footnotes.

$content = "Visit our website at <a href=''></a> and read our blog post at <a href=''></a>.";

$content_with_footnotes = make_url_footnote($content);

// Output: "Visit our website at [1] and read our blog post at [2]. [1] [2]"

Strip links from a WooCommerce product description and place them as footnotes.

$product_description = "Learn more about our product at <a href=''></a>.";

$product_description_with_footnotes = make_url_footnote($product_description);

// Output: "Learn more about our product at [1]. [1]"

Handle multiple paragraphs

Convert links within multiple paragraphs to footnotes.

$content = "<p>Welcome to our blog. Visit our homepage at <a href=''></a>.</p><p>Read our latest article at <a href=''></a>.</p>";

$content_with_footnotes = make_url_footnote($content);

// Output: "<p>Welcome to our blog. Visit our homepage at [1].</p><p>Read our latest article at [2].</p> [1] [2]"

Process user comments

Strip links from user comments and place them as footnotes to avoid link spamming.

$comment_content = "Check out this amazing website: <a href=''></a>.";

$comment_content_with_footnotes = make_url_footnote($comment_content);

// Output: "Check out this amazing website: [1]. [1]"

Process content with no links; the function returns the original content unaltered.

$content = "This is a sample content with no links.";

$content_with_footnotes = make_url_footnote($content);

// Output: "This is a sample content with no links."