snipt

Ctrl+h for KB shortcuts

PHP

Excluir current post del query

'post__not_in' => array( $post->ID )
https://snipt.net/embed/5ec4e40e664d6057d2185cc9e3a17c8e/
/raw/5ec4e40e664d6057d2185cc9e3a17c8e/
5ec4e40e664d6057d2185cc9e3a17c8e
php
PHP
1
2019-05-31T09:29:06
True
False
False
Dec 20, 2012 at 02:46 PM
/api/public/snipt/52152/
excluir-current-post-del-query
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">&#39;post__not_in&#39; =&gt; array( $post-&gt;ID )</span> </span></pre></div> </td></tr></table>
current, post, query, wordpress

PHP

Joomla MySQL database query

1
2
3
4
5
6
7
8
<?php
    $db =& JFactory::getDBO(); 
    $query = "SELECT title FROM #__table WHERE id=307";
    $db->setQuery($query);
    $text= $db->loadResult();
?>

<h4>Result: <?php echo $text; ?></h4>
https://snipt.net/embed/6b9e2f149b0f7486d413f625249e35c6/
/raw/6b9e2f149b0f7486d413f625249e35c6/
6b9e2f149b0f7486d413f625249e35c6
php
PHP
8
2019-06-14T06:08:33
True
False
False
/api/public/snipt/48854/
joomla-mysql-database-query
<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> <a href="#L-7">7</a> <a href="#L-8">8</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">$db</span> <span class="o">=&amp;</span> <span class="nx">JFactory</span><span class="o">::</span><span class="na">getDBO</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$query</span> <span class="o">=</span> <span class="s2">&quot;SELECT title FROM #__table WHERE id=307&quot;</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$db</span><span class="o">-&gt;</span><span class="na">setQuery</span><span class="p">(</span><span class="nv">$query</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="nv">$text</span><span class="o">=</span> <span class="nv">$db</span><span class="o">-&gt;</span><span class="na">loadResult</span><span class="p">();</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="x">&lt;h4&gt;Result: </span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$text</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x">&lt;/h4&gt;</span> </span></pre></div> </td></tr></table>
database, joomla, mysql, query

PHP

Display latest posts from a certain category

1
2
3
<?php $recent = new WP_Query("cat=3&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
https://snipt.net/embed/e62df76dabe04d6cc06ce4669da5132a/
/raw/e62df76dabe04d6cc06ce4669da5132a/
e62df76dabe04d6cc06ce4669da5132a
php
PHP
3
2019-06-05T21:21:55
True
False
False
/api/public/snipt/39980/
display-latest-posts-from-a-certain-category
<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">$recent</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">WP_Query</span><span class="p">(</span><span class="s2">&quot;cat=3&amp;showposts=3&quot;</span><span class="p">);</span> <span class="k">while</span><span class="p">(</span><span class="nv">$recent</span><span class="o">-&gt;</span><span class="na">have_posts</span><span class="p">())</span> <span class="o">:</span> <span class="nv">$recent</span><span class="o">-&gt;</span><span class="na">the_post</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;li&gt;&lt;a href=&quot;</span><span class="cp">&lt;?php</span> <span class="nx">the_permalink</span><span class="p">();</span> <span class="cp">?&gt;</span><span class="x">&quot;&gt;</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">&lt;/a&gt;&lt;/li&gt;</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">&lt;?php</span> <span class="k">endwhile</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
"category 1", php, posts, query

CSS

Media query for iPhone 4

@media only screen and (-webkit-min-device-pixel-ratio: 2) { }
https://snipt.net/embed/d1479c051b595823de4b2921a8e962e9/
/raw/d1479c051b595823de4b2921a8e962e9/
d1479c051b595823de4b2921a8e962e9
css
CSS
1
2019-06-17T09:32:11
True
False
False
/api/public/snipt/35154/
media-query-for-iphone-4
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">@media</span> <span class="nt">only</span> <span class="nt">screen</span> <span class="nt">and</span> <span class="o">(</span><span class="nt">-webkit-min-device-pixel-ratio</span><span class="o">:</span> <span class="nt">2</span><span class="o">)</span> <span class="p">{</span> <span class="p">}</span> </span></pre></div> </td></tr></table>
media, query

CSS

Media query ratio

@media screen and (device-aspect-ratio: 16/9) {  }
https://snipt.net/embed/bf7e4861cf0e5c6be99fcc17dd02cfda/
/raw/bf7e4861cf0e5c6be99fcc17dd02cfda/
bf7e4861cf0e5c6be99fcc17dd02cfda
css
CSS
1
2019-06-17T09:31:17
True
False
False
/api/public/snipt/35153/
media-query-ratio
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">@media</span> <span class="nt">screen</span> <span class="nt">and</span> <span class="o">(</span><span class="nt">device-aspect-ratio</span><span class="o">:</span> <span class="nt">16</span><span class="o">/</span><span class="nt">9</span><span class="o">)</span> <span class="p">{</span> <span class="p">}</span> </span></pre></div> </td></tr></table>
media, query