snipt

Ctrl+h for KB shortcuts

PHP

WordPress - Convert text URL into a link

1
2
3
4
5
6
function make_text_links() 
{
	$string = get_the_content();
	return make_clickable($string);
}
add_filter( 'the_content', 'make_text_links' );
https://snipt.net/embed/b0f50c02c96045fe1b6db318eb227519/
/raw/b0f50c02c96045fe1b6db318eb227519/
b0f50c02c96045fe1b6db318eb227519
php
PHP
6
2019-06-26T12:25:45
True
False
False
Jan 05, 2014 at 11:34 PM
/api/public/snipt/103981/
wordpress-convert-text-url-into-a-link
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">function make_text_links() </span> </span><span id="L-2"><a name="L-2"></a><span class="x">{</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> $string = get_the_content();</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> return make_clickable($string);</span> </span><span id="L-5"><a name="L-5"></a><span class="x">}</span> </span><span id="L-6"><a name="L-6"></a><span class="x">add_filter( &#39;the_content&#39;, &#39;make_text_links&#39; );</span> </span></pre></div> </td></tr></table>
URL, WordPress, link