snipt

Ctrl+h for KB shortcuts

PHP

Change the height of the excerpt field in WP-Admin

1
2
3
4
5
6
7
<?php
// excerpt height
function admin_excerpt() {
	echo "<style>"; echo "textarea#excerpt {height: 200px;}"; echo "</style>";
}
add_action('admin_head', 'admin_excerpt');
?>
https://snipt.net/embed/e8da786b65f7057ab62ebc8a6f534cde/
/raw/e8da786b65f7057ab62ebc8a6f534cde/
e8da786b65f7057ab62ebc8a6f534cde
php
PHP
7
2019-08-18T05:10:13
True
False
False
/api/public/snipt/18762/
change-the-height-of-the-excerpt-field-in-wp-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> <a href="#L-6">6</a> <a href="#L-7">7</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="c1">// excerpt height</span> </span><span id="L-3"><a name="L-3"></a><span class="k">function</span> <span class="nf">admin_excerpt</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">echo</span> <span class="s2">&quot;&lt;style&gt;&quot;</span><span class="p">;</span> <span class="k">echo</span> <span class="s2">&quot;textarea#excerpt {height: 200px;}&quot;</span><span class="p">;</span> <span class="k">echo</span> <span class="s2">&quot;&lt;/style&gt;&quot;</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span><span id="L-6"><a name="L-6"></a><span class="nx">add_action</span><span class="p">(</span><span class="s1">&#39;admin_head&#39;</span><span class="p">,</span> <span class="s1">&#39;admin_excerpt&#39;</span><span class="p">);</span> </span><span id="L-7"><a name="L-7"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
excerpt, wordpress, wp-admin

PHP

Number of posts in a loop

<?php $number_of_posts = $wp_query->post_count; ?>
https://snipt.net/embed/e6e7a5f3b3efb31bac160a5f254600e6/
/raw/e6e7a5f3b3efb31bac160a5f254600e6/
e6e7a5f3b3efb31bac160a5f254600e6
php
PHP
1
2019-08-18T02:47:25
True
False
False
/api/public/snipt/17003/
number-of-posts-in-a-loop
<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="cp">&lt;?php</span> <span class="nv">$number_of_posts</span> <span class="o">=</span> <span class="nv">$wp_query</span><span class="o">-&gt;</span><span class="na">post_count</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
wordpress

PHP

Returns the number of results

<?php echo $wp_query->found_posts; ?>
https://snipt.net/embed/8ab983b26990fbcd4421a5dbe746a118/
/raw/8ab983b26990fbcd4421a5dbe746a118/
8ab983b26990fbcd4421a5dbe746a118
php
PHP
1
2019-08-16T14:48:01
True
False
False
/api/public/snipt/12535/
returns-the-number-of-results
<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="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$wp_query</span><span class="o">-&gt;</span><span class="na">found_posts</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
count, number, results, wordpress

PHP

Returns the searched keyword

<?php echo get_search_query(); ?>
https://snipt.net/embed/a170a61d1ebba5b7174e89e025159544/
/raw/a170a61d1ebba5b7174e89e025159544/
a170a61d1ebba5b7174e89e025159544
php
PHP
1
2019-08-18T12:16:47
True
False
False
/api/public/snipt/12533/
returns-the-searched-keyword
<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="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">get_search_query</span><span class="p">();</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
"search query", keyword, search, wordpress