snipt

Ctrl+h for KB shortcuts

PHP

Get specific page teaser in Wordpress (text before more tag)

1
2
3
4
5
6
7
<?php
$page_id = 5824;
$page_data = get_page( $page_id );
$exploded = explode("<!--more-->",$page_data->post_content);
$the_content = apply_filters('the_content',$exploded[0]);
echo $the_content;
?>
https://snipt.net/embed/465105f49273b0b46ee827a346b88219/
/raw/465105f49273b0b46ee827a346b88219/
465105f49273b0b46ee827a346b88219
php
PHP
7
2016-12-27T08:05:47
True
False
True
Jan 16, 2013 at 09:13 PM
/api/public/snipt/53861/
get-specific-page-teaser-in-wordpress-text-before-more-tag
<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="nv">$page_id</span> <span class="o">=</span> <span class="mi">5824</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">$page_data</span> <span class="o">=</span> <span class="nx">get_page</span><span class="p">(</span> <span class="nv">$page_id</span> <span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">$exploded</span> <span class="o">=</span> <span class="nb">explode</span><span class="p">(</span><span class="s2">&quot;&lt;!--more--&gt;&quot;</span><span class="p">,</span><span class="nv">$page_data</span><span class="o">-&gt;</span><span class="na">post_content</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="nv">$the_content</span> <span class="o">=</span> <span class="nx">apply_filters</span><span class="p">(</span><span class="s1">&#39;the_content&#39;</span><span class="p">,</span><span class="nv">$exploded</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span> </span><span id="L-6"><a name="L-6"></a><span class="k">echo</span> <span class="nv">$the_content</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>
functions.php, page, wordpress

Batchfile

Run all files in current folder bat file

1
2
3
:: Run all files in current folder
:: No spaces in files' names! (Except this bat file name - so it won't start files forever in recursion)
for /r %%i in (*) do start %%i
https://snipt.net/embed/8ab47e79080e32d0f41c876afdd02bc8/
/raw/8ab47e79080e32d0f41c876afdd02bc8/
8ab47e79080e32d0f41c876afdd02bc8
bat
Batchfile
3
2019-07-14T02:24:14
True
False
False
Feb 12, 2013 at 01:25 PM
/api/public/snipt/53825/
run-all-files-in-current-folder-bat-file
<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="p">:</span><span class="c1">: Run all files in current folder</span> </span><span id="L-2"><a name="L-2"></a><span class="p">:</span><span class="c1">: No spaces in files&#39; names! (Except this bat file name - so it won&#39;t start files forever in recursion)</span> </span><span id="L-3"><a name="L-3"></a><span class="k">for</span> /r <span class="se">%%</span>i <span class="k">in</span> <span class="p">(</span>*<span class="p">)</span> <span class="k">do</span> <span class="k">start</span> <span class="se">%%</span>i </span></pre></div> </td></tr></table>
batch, file