snipt

Ctrl+h for KB shortcuts

PHP

Asignar Clase a Thumbnail Wordpress

1
2
3
4
5
<?php if ( has_post_thumbnail() ) { 
the_post_thumbnail('servicio', array('class' => 'nombre_clase'));
} else { ?>
<img src="http://placehold.it/475x266/" />
<?php } ?>
https://snipt.net/embed/3ffd6aa12d86b30c2bae1e69c77abb65/
https://snipt.net/raw/3ffd6aa12d86b30c2bae1e69c77abb65/
3ffd6aa12d86b30c2bae1e69c77abb65
php
PHP
5
2016-09-26T14:46:20
True
False
False
Jul 18, 2013 at 11:14 AM
/api/public/snipt/68410/
asignar-clase-a-thumbnail-wordpress
<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 class="k">if</span> <span class="p">(</span> <span class="nx">has_post_thumbnail</span><span class="p">()</span> <span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">the_post_thumbnail</span><span class="p">(</span><span class="s1">&#39;servicio&#39;</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;class&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;nombre_clase&#39;</span><span class="p">));</span> </span><span id="L-3"><a name="L-3"></a><span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-4"><a name="L-4"></a><span class="x">&lt;img src=&quot;http://placehold.it/475x266/&quot; /&gt;</span> </span><span id="L-5"><a name="L-5"></a><span class="cp">&lt;?php</span> <span class="p">}</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
array, thumbnail, wordpress

HTML+PHP

Thumbnail Post (Featured image) / with default

1
2
3
4
5
6
<?php 
    if ( has_post_thumbnail() ) { 
  		the_post_thumbnail('defined size'); // define size of thumb
	} else { ?>	<!-- if don't exist use -->
		<img src="<?php bloginfo('template_url'); ?>/img/path/file.jpg">
<?php } ?>
https://snipt.net/embed/0f66290607c1f219f42057b3fbbc3788/
https://snipt.net/raw/0f66290607c1f219f42057b3fbbc3788/
0f66290607c1f219f42057b3fbbc3788
html+php
HTML+PHP
6
2016-09-25T14:13:35
True
False
False
/api/public/snipt/42207/
thumbnail-post-featured-image-with-default
<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">if</span> <span class="p">(</span> <span class="nx">has_post_thumbnail</span><span class="p">()</span> <span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">the_post_thumbnail</span><span class="p">(</span><span class="s1">&#39;defined size&#39;</span><span class="p">);</span> <span class="c1">// define size of thumb</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="cp">?&gt;</span> <span class="c">&lt;!-- if don&#39;t exist use --&gt;</span> </span><span id="L-5"><a name="L-5"></a> <span class="nt">&lt;img</span> <span class="na">src=</span><span class="s">&quot;</span><span class="cp">&lt;?php</span> <span class="nx">bloginfo</span><span class="p">(</span><span class="s1">&#39;template_url&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="s">/img/path/file.jpg&quot;</span><span class="nt">&gt;</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">&lt;?php</span> <span class="p">}</span> <span class="cp">?&gt;</span> </span></pre></div> </td></tr></table>
"default image", featured, image, thumb, thumbnail, wordpress

HTML+PHP

Galeria Wordpress / Gallery wordpress exclude post thumbnail

1
2
3
4
<?php  
$id = get_post_thumbnail_id(get_the_ID()); // gets the post thumbnail ID 
echo do_shortcode('[gallery exclude='.$id.' link="file" itemtag="ul" icontag="li" columns="4" size="galeria"]'); 
?>
https://snipt.net/embed/ba0005f21b3d3537f983c9dbad387d85/
https://snipt.net/raw/ba0005f21b3d3537f983c9dbad387d85/
ba0005f21b3d3537f983c9dbad387d85
html+php
HTML+PHP
4
2016-09-22T18:40:55
True
False
False
/api/public/snipt/42206/
galeria-wordpress-gallery-wordpress-exclude-post-thumbnail
<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">$id</span> <span class="o">=</span> <span class="nx">get_post_thumbnail_id</span><span class="p">(</span><span class="nx">get_the_ID</span><span class="p">());</span> <span class="c1">// gets the post thumbnail ID </span> </span><span id="L-3"><a name="L-3"></a><span class="k">echo</span> <span class="nx">do_shortcode</span><span class="p">(</span><span class="s1">&#39;[gallery exclude=&#39;</span><span class="o">.</span><span class="nv">$id</span><span class="o">.</span><span class="s1">&#39; link=&quot;file&quot; itemtag=&quot;ul&quot; icontag=&quot;li&quot; columns=&quot;4&quot; size=&quot;galeria&quot;]&#39;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="cp">?&gt;</span> </span></pre></div> </td></tr></table>
exclude, gallery, thumbnail, wordpress

PHP

Featured Image por defecto en Wordpress

1
2
3
<?php if ( has_post_thumbnail() ) { the_post_thumbnail('thumb-post'); } else { ?>
<img src="<?php bloginfo('template_directory'); ?>/images/rutadela.imagen" alt="<?php the_title(); ?>" />
<?php } ?>
https://snipt.net/embed/32e3ea1d38f371e7697ed16bebade38a/
https://snipt.net/raw/32e3ea1d38f371e7697ed16bebade38a/
32e3ea1d38f371e7697ed16bebade38a
php
PHP
3
2016-09-14T17:25:09
True
False
False
/api/public/snipt/41359/
featured-image-por-defecto-en-wordpress
<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="k">if</span> <span class="p">(</span> <span class="nx">has_post_thumbnail</span><span class="p">()</span> <span class="p">)</span> <span class="p">{</span> <span class="nx">the_post_thumbnail</span><span class="p">(</span><span class="s1">&#39;thumb-post&#39;</span><span class="p">);</span> <span class="p">}</span> <span class="k">else</span> <span class="p">{</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 src=&quot;</span><span class="cp">&lt;?php</span> <span class="nx">bloginfo</span><span class="p">(</span><span class="s1">&#39;template_directory&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">/images/rutadela.imagen&quot; alt=&quot;</span><span class="cp">&lt;?php</span> <span class="nx">the_title</span><span class="p">();</span> <span class="cp">?&gt;</span><span class="x">&quot; /&gt;</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">&lt;?php</span> <span class="p">}</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
featured-image, php, thumbnail, wordpress
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.