snipt

Ctrl+h for KB shortcuts

PHP

Imprimir contenido de una página específica en Wordpress

1
2
3
4
<?php $recent = new WP_Query("page_id=nºpage"); while($recent->have_posts()) : $recent->the_post();?>
// bla bla bla
<?php endwhile;?>
<?php wp_reset_query(); ?>
https://snipt.net/embed/84d16168e1c3fe90a3b9823f76baf248/
/raw/84d16168e1c3fe90a3b9823f76baf248/
84d16168e1c3fe90a3b9823f76baf248
php
PHP
4
2019-07-22T09:41:34
True
False
False
Dec 21, 2012 at 01:55 PM
/api/public/snipt/41355/
imprimir-contenido-de-una-pagina-especifica-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> <a href="#L-4">4</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;page_id=nºpage&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">// bla bla bla</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><span id="L-4"><a name="L-4"></a><span class="cp">&lt;?php</span> <span class="nx">wp_reset_query</span><span class="p">();</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
loop, page, php, wordpress