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/
/raw/4a10b2569440fc459f8620ddd46dd4e3/
4a10b2569440fc459f8620ddd46dd4e3
php
PHP
3
2019-05-19T18:30:38
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

PHP

WordPress template tag to display the name/title of PARENT page.

1
2
3
4
<?php
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
?>
https://snipt.net/embed/c8c2347c8a3ad9b9ddfb265764347707/
/raw/c8c2347c8a3ad9b9ddfb265764347707/
c8c2347c8a3ad9b9ddfb265764347707
php
PHP
5
2019-05-22T08:53:23
True
False
False
May 05, 2016 at 12:13 PM
/api/public/snipt/146151/
wordpress-template-tag-to-display-the-nametitle-of-parent-page
<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></span><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">$parent_title</span> <span class="o">=</span> <span class="nx">get_the_title</span><span class="p">(</span><span class="nv">$post</span><span class="o">-&gt;</span><span class="na">post_parent</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="k">echo</span> <span class="nv">$parent_title</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>
wordpress