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/
https://snipt.net/raw/b0f50c02c96045fe1b6db318eb227519/
b0f50c02c96045fe1b6db318eb227519
php
PHP
6
2016-09-26T13:43:54
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 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

Text only

URL Latitude Google Maps

1
2
3
4
-32.675991,-71.441364 (Latitude ej)
maps.google.cl/maps?q=

https://maps.google.cl/maps?q=-32.675991,-71.441364
https://snipt.net/embed/60a57bd28c537f85f58d8760fd3ebf1c/
https://snipt.net/raw/60a57bd28c537f85f58d8760fd3ebf1c/
60a57bd28c537f85f58d8760fd3ebf1c
text
Text only
5
2016-09-22T12:58:22
True
False
True
Dec 05, 2013 at 11:39 PM
/api/public/snipt/43103/
url-latitude-google-maps
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>-32.675991,-71.441364 (Latitude ej) </span><span id="L-2"><a name="L-2"></a>maps.google.cl/maps?q= </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>https://maps.google.cl/maps?q=-32.675991,-71.441364 </span></pre></div> </td></tr></table>
Latitude, Maps, URL

PHP

Featured Image URL

1
2
3
4
<?php
 $img_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");
 echo $img_url[0];
 ?>
https://snipt.net/embed/2554e2f9b25a2e9291a0b5f51f7fa897/
https://snipt.net/raw/2554e2f9b25a2e9291a0b5f51f7fa897/
2554e2f9b25a2e9291a0b5f51f7fa897
php
PHP
4
2016-09-24T10:35:55
True
False
False
/api/public/snipt/38998/
featured-image-url
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> <span class="nv">$img_url</span> <span class="o">=</span> <span class="nx">wp_get_attachment_image_src</span><span class="p">(</span> <span class="nx">get_post_thumbnail_id</span><span class="p">(</span> <span class="nv">$post</span><span class="o">-&gt;</span><span class="na">ID</span> <span class="p">),</span> <span class="s2">&quot;Full&quot;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">echo</span> <span class="nv">$img_url</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span> </span><span id="L-4"><a name="L-4"></a> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
Featured, Image, URL, wordpress
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.