En este momento estás viendo Cómo mostrar cualquier número de publicaciones en un bucle de WordPress

Cómo mostrar cualquier número de publicaciones en un bucle de WordPress

free hosting wordpress
free hosting wordpress

la soga es utilizado por WordPress para mostrar cada una de sus publicaciones. Usando The Loop, WordPress procesa cada una de las publicaciones para mostrarlas en la página actual y les da formato en función de cómo coinciden con los criterios especificados en las etiquetas de The Loop. Normalmente, la cantidad de publicaciones para mostrar se establece en el área de Configuración del panel de administración de WordPress en la pestaña de lecturas. Pero en este artículo, le mostraremos cómo ignorar ese número usando un Super Loop que le permitirá ver cualquier cantidad de publicaciones en ese bucle específico de WordPress. Esto le permitirá personalizar la visualización de sus páginas, incluidos los perfiles de autor, las barras laterales y más.

Abra un archivo de plantilla donde desee colocar las publicaciones y luego simplemente agregue este bucle:

// if everything is in place and ready, let's start the loop
 
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

// to display 'n' number of posts, we need to execute the loop 'n' number of times
// so we define a numerical variable called '$count' and set its value to zero
// with each iteration of the loop, the value of '$count' will increase by one
// after the value of '$count' reaches the specified number, the loop will stop
// *USER: change the 'n' to the number of posts that you would like to display

<?php static $count = 0;
if ($count == "n") { break; }
else { ?>

// for CSS styling and layout purposes, we wrap the post content in a div
// we then display the entire post content via the 'the_content()' function
// *USER: change to '<?php the_excerpt(); ?>' to display post excerpts instead

<div class="post">
<?php the_title(); ?>
<?php the_content(); ?>
</div>

// here, we continue with the limiting of the number of displayed posts
// each iteration of the loop increases the value of '$count' by one
// the final two lines complete the loop and close the if statement

<?php $count++; } ?>
<?php endwhile; ?>
<?php endif; ?>

Y ya está. Este código te será muy útil, especialmente cuando diseñes la plantilla de autor porque te gustaría controlar la cantidad de publicaciones que se muestran en cada ciclo.

Fuente: Súper bucle para WordPress

Cómo mostrar cualquier número de publicaciones en un bucle de WordPress




Comportamiento

11





Para compartir





Para compartir





Alfiler





Facebook Messenger





Whatsapp





Correo electrónico


la soga es utilizado por WordPress para mostrar cada una de sus publicaciones. Usando The Loop, WordPress procesa cada una de las publicaciones para mostrarlas en la página actual y les da formato en función de cómo coinciden con los criterios especificados en las etiquetas de The Loop. Normalmente, la cantidad de publicaciones para mostrar se establece en el área de Configuración del panel de administración de WordPress en la pestaña de lecturas. Pero en este artículo, le mostraremos cómo ignorar ese número usando un Super Loop que le permitirá ver cualquier cantidad de publicaciones en ese bucle específico de WordPress. Esto le permitirá personalizar la visualización de sus páginas, incluidos los perfiles de autor, las barras laterales y más.

Abra un archivo de plantilla donde desee colocar las publicaciones y luego simplemente agregue este bucle:

// if everything is in place and ready, let's start the loop
 
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

// to display 'n' number of posts, we need to execute the loop 'n' number of times
// so we define a numerical variable called '$count' and set its value to zero
// with each iteration of the loop, the value of '$count' will increase by one
// after the value of '$count' reaches the specified number, the loop will stop
// *USER: change the 'n' to the number of posts that you would like to display

<?php static $count = 0;
if ($count == "n") { break; }
else { ?>

// for CSS styling and layout purposes, we wrap the post content in a div
// we then display the entire post content via the 'the_content()' function
// *USER: change to '<?php the_excerpt(); ?>' to display post excerpts instead

<div class="post">
<?php the_title(); ?>
<?php the_content(); ?>
</div>

// here, we continue with the limiting of the number of displayed posts
// each iteration of the loop increases the value of '$count' by one
// the final two lines complete the loop and close the if statement

<?php $count++; } ?>
<?php endwhile; ?>
<?php endif; ?>

Y ya está. Este código te será muy útil, especialmente cuando diseñes la plantilla de autor porque te gustaría controlar la cantidad de publicaciones que se muestran en cada ciclo.

Fuente: Súper bucle para WordPress




Comportamiento

11





Para compartir





Para compartir





Alfiler





Facebook Messenger





Whatsapp





Correo electrónico


free hosting wordpress
free hosting wordpress
#WordPress #Hosting #vps #seo #sem

Deja una respuesta