Wordpress how can I create multiple loops in the index?

Asked

Viewed 98 times

0

I’m trying to create several loops on my index in wordpress , I wanted to call the posts as follows:

Releases: showing only 6 posts. Series: Showing only 6 posts. Recent Movies: Showing only 6 posts with paging.

I have tried and manage to put the pagination does not work very well when it goes to page 2 I wanted q show only the last posts more she makes pagination in Launches and Series tmb.

In short I wanted a similar index of this site: efilmesnarede.com

  • In the index of the example site it seems to me just a link to the /page/2, being the index a custom index and the /page/2 a page of Archive with pagination. In thesis: Index = a page with 3 loopings and a /page/2 = a file page with only one looping of the most recent films and with pagination.

1 answer

0

It is simple, for this Wordpress has the array filter while( have_posts( ) ) I’m going to go through here as the code should be, I commented on it to show you:

<?php
$args = array('showposts'  => 5,  # Quantidade de Posts a serem Mostrados, use -1 para puxar todos!
              'post_status' => 'publish', # PEGA APENAS POSTAGENS PUBLICADAS.
              'category_name' => 'lancamentos'; # PEGA OS POSTS PELA CATEGORIA.
            );

    $wp_query = new WP_Query( $args ); # PEGA OS ARGUMENTOS SETADO ACIMA!

    if(have_posts()) : while(have_posts()) : the_post(); # VERIFICA SE TEM POSTAGENS.
?>

       CÓDIGO QUE DEVE SER REPETIDO FICA AQUI! 

<?php endwhile; endif; # FIM DA VERIFICAÇÃO DE POSTAGENS. # CASO QUEIRA, USE UM ELSE: NO WHILE FICANDO ELSE: ENDWHILE; ENDIF; E NO ELSE COLOQUE O CODIGO 404.
wp_reset_query(); # RESETA O QUERY PARA NÃO TER CONFLITO NOS PRÓXIMO LOOPS ABAIXO ?>

Good luck in your system!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.