Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

Interchange Image Wordpress Carrusel ACF

1
2
3
<?php $image = get_sub_field('NOMBRE_SUB_FIELD'); if( $image ): ?>
<img data-interchange="[<?php echo $image['sizes']['CUSTOM_SIZE']; ?>, small], [<?php echo $image['sizes']['CUSTOM_SIZE']; ?>, medium], [<?php echo $image['sizes']['CUSTOM_SIZE']; ?>, large]">
<?php endif; ?>
https://snipt.net/embed/4a10b2569440fc459f8620ddd46dd4e3/
https://snipt.net/raw/4a10b2569440fc459f8620ddd46dd4e3/
4a10b2569440fc459f8620ddd46dd4e3
php
PHP
3
2016-12-08T05:13:14
True
False
False
Aug 05, 2016 at 05:17 PM
/api/public/snipt/147506/
interchange-image-wordpress-carrusel-acf
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> <span class="nv">$image</span> <span class="o">=</span> <span class="nx">get_sub_field</span><span class="p">(</span><span class="s1">&#39;NOMBRE_SUB_FIELD&#39;</span><span class="p">);</span> <span class="k">if</span><span class="p">(</span> <span class="nv">$image</span> <span class="p">)</span><span class="o">:</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-2"><a name="L-2"></a><span class="x">&lt;img data-interchange=&quot;[</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$image</span><span class="p">[</span><span class="s1">&#39;sizes&#39;</span><span class="p">][</span><span class="s1">&#39;CUSTOM_SIZE&#39;</span><span class="p">];</span> <span class="cp">?&gt;</span><span class="x">, small], [</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$image</span><span class="p">[</span><span class="s1">&#39;sizes&#39;</span><span class="p">][</span><span class="s1">&#39;CUSTOM_SIZE&#39;</span><span class="p">];</span> <span class="cp">?&gt;</span><span class="x">, medium], [</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$image</span><span class="p">[</span><span class="s1">&#39;sizes&#39;</span><span class="p">][</span><span class="s1">&#39;CUSTOM_SIZE&#39;</span><span class="p">];</span> <span class="cp">?&gt;</span><span class="x">, large]&quot;&gt;</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">&lt;?php</span> <span class="k">endif</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
acf, carrusel, wordpress

Text only

Advanced Custom Fields: Hide If No Content In Admin

1
2
3
4
5
<?php if(!get_field('alert', 'option')){ }else{?>
	<div id="alert">
		<?php the_field('alert', 'option'); ?>
	</div>	
<?php } ?>
https://snipt.net/embed/b7aeb3065255cd52bc4ecc9c8f88987f/
https://snipt.net/raw/b7aeb3065255cd52bc4ecc9c8f88987f/
b7aeb3065255cd52bc4ecc9c8f88987f
text
Text only
5
2016-12-07T06:52:35
True
False
False
/api/public/snipt/135578/
advanced-custom-fields-hide-if-no-content-in-admin-953007a5
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>&lt;?php if(!get_field(&#39;alert&#39;, &#39;option&#39;)){ }else{?&gt; </span><span id="L-2"><a name="L-2"></a> &lt;div id=&quot;alert&quot;&gt; </span><span id="L-3"><a name="L-3"></a> &lt;?php the_field(&#39;alert&#39;, &#39;option&#39;); ?&gt; </span><span id="L-4"><a name="L-4"></a> &lt;/div&gt; </span><span id="L-5"><a name="L-5"></a>&lt;?php } ?&gt; </span></pre></div> </td></tr></table>
acf, php
Copyrighted, illegal, or inappropriate content? Email [email protected].