Desarrollo del programa

WordPress llama a un artículo de categoría para compartir código

<? php //cat es el ID de la columna showposts es el número de llamadas query_posts ('t [...]

Catálogo de artículos

<? El PHP
/ / cat es el ID de columna showposts es el número de llamadas
query_posts('tag=app&cat=1&showposts=1');
?>
<ul style="float:left">
<? php if (have_posts()) :while (have_posts()) : the_post();?>
<li>
&lt; a href = " &lt;? php el _ permalink ()? &gt; " ><? php the_title();?&gt; </a>&lt;! - Título - &gt;
</li>
<? php endwhile; endif;? &gt;
</ul>
<? PHP wp_reset_query();? &gt;

El código anterior es llamar a un artículo etiquetado con una aplicación en el id de categoría 1. Tag, cat, showposts Estos tres atributos no se agregan todos, puede ver que necesita agregar atributos, si todavía desea llamar al código del artículo con imágenes de la siguiente manera, pero antes de agregar código, necesita agregar en la plantilla de función

Función catch _ that _ image () {
$post global, $posts;
$first _ img = ";
ob _ start ();
ob _ end _ clean();
$output = preg_match_all('/ &lt; img.+ src=[']([^']+)['].*&gt;/ i', $post-&gt; post _ content, $matches);
$first _ img = $coincidencias [1] [0];
if(empty($first_img)) {// Define una imagen predeterminada
$first_img = "/images/default.jpg";
}
retorno de $first_img;
}

Después de agregar, el código de llamada es el siguiente

 

<? El PHP
/ / cat es el ID de columna showposts es el número de llamadas
query_posts('tag=app&showposts=1');
?>
<ul style="float:left">
<? php if (have_posts()) :while (have_posts()) : the_post();?>
<li>
< img src = » <? php echo catch_that_image();?> »¿Alt = »? php the_title();?> " width = 228px, height = 105px /> <! - Miniaturas - >
&lt; a href = " &lt;? php el _ permalink ()? &gt; " ><? php the_title();?&gt; </a>&lt;! - Título - &gt;
</li>
<? php endwhile; endif;? &gt;
</ul>
<? PHP wp_reset_query();? &gt;