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-09-25T14:04:05
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 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

Change WordPress URL search base

1
2
3
4
5
6
<?php
function vital_custom_search_base() {
    $GLOBALS['wp_rewrite']->search_base = 'search-results';
}

add_action( 'init', 'vital_custom_search_base' );
https://snipt.net/embed/014873dfcc188991ccee13318ce8a89d/
https://snipt.net/raw/014873dfcc188991ccee13318ce8a89d/
014873dfcc188991ccee13318ce8a89d
php
PHP
6
2016-09-24T14:06:55
True
False
False
Jul 05, 2016 at 03:15 PM
/api/public/snipt/147339/
change-wordpress-url-search-base
<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="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="k">function</span> <span class="nf">vital_custom_search_base</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$GLOBALS</span><span class="p">[</span><span class="s1">&#39;wp_rewrite&#39;</span><span class="p">]</span><span class="o">-&gt;</span><span class="na">search_base</span> <span class="o">=</span> <span class="s1">&#39;search-results&#39;</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="nx">add_action</span><span class="p">(</span> <span class="s1">&#39;init&#39;</span><span class="p">,</span> <span class="s1">&#39;vital_custom_search_base&#39;</span> <span class="p">);</span> </span></pre></div> </td></tr></table>
permalinks, rewrite, wordpress

PHP

Get current page in WordPress admin

1
2
3
4
5
<?php
$current_screen = get_current_screen();
if ($current_screen->id === 'plugins') {
// http://codex.wordpress.org/Plugin_API/Admin_Screen_Reference
}
https://snipt.net/embed/6ebcd5ed617384a8fe068f24a6d354b9/
https://snipt.net/raw/6ebcd5ed617384a8fe068f24a6d354b9/
6ebcd5ed617384a8fe068f24a6d354b9
php
PHP
5
2016-09-24T14:07:31
True
False
False
Jun 16, 2016 at 08:46 AM
/api/public/snipt/147210/
get-current-page-in-wordpress-admin
<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 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">$current_screen</span> <span class="o">=</span> <span class="nx">get_current_screen</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a><span class="k">if</span> <span class="p">(</span><span class="nv">$current_screen</span><span class="o">-&gt;</span><span class="na">id</span> <span class="o">===</span> <span class="s1">&#39;plugins&#39;</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a><span class="c1">// http://codex.wordpress.org/Plugin_API/Admin_Screen_Reference</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
admin, dashboard, wordpress
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.