Suporte » Plugins » Dúvida de loop com paginação

  • Galera, tenho o seguinte código, e gostaria de saber como faço para inserir uma paginação neste loop, por exemplo, toda vez que aparecer o box5 ele insira uma paginação

    $q = new WP_Query(
    array(‘posts_per_page’ => -1, ‘post_type’ => ‘rd-hover’, ‘hover_cat’ => $category)
    );

    while($q->have_posts()) : $q->the_post();
    $id = get_the_ID();

    $rdmeta = vp_metabox(‘rdmeta.rd-hover’, false);

    $i = 0;
    $x = 1;

    $output = ‘<div id=”‘.$style.'”>

      ‘;

    foreach ($rdmeta as $info) {

    if ($effects==”square”) {
    if ($x == 1)
    $box = ‘box1’;
    if ($x == 2)
    $box = ‘box2’;
    if ($x == 3)
    $box = ‘box3’;
    if ($x == 4)
    $box = ‘box4’;
    $output .= ‘
    <style type=”text/css”>
    @import url(http://fonts.googleapis.com/css?family=&#8217;.$google_font.’);
    </style>
    <div id=”‘.$box.'” class=”rakib-dev rakib-dev-first”>
    <img src=”‘.$info[‘imgup_1’].'” />
    <div class=”mask”>
    <h2>’.$info[‘title’].'</h2>
    <p>’.$info[‘desc’].'</p>
    ‘.$info[‘link_title’].’
    </div>
    <h2>’.$info[‘ttext’].'</h2>
    <p>’.$info[‘textf’].'</p>
    </div>

    ;

    }
    if ($x == 4)
    $x = 1;
    else
    $x++;

Visualizando 2 respostas - 1 até 2 (de um total de 2)
  • Tenta assim:

    <?php
    $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
    
    $args = array(
    	'posts_per_page' => 5,
    	'post_type' => 'rd-hover',
    	'paged' => $paged,
    );
    
    $the_query = new WP_Query( $args );
    ?>
    <!-- the loop etc.. -->
    
    <?php
    $big = 999999999;
    
    echo paginate_links( array(
    	'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    	'format' => '?paged=%#%',
    	'current' => max( 1, get_query_var('paged') ),
    	'total' => $the_query->max_num_pages
    ) );
    ?>

    Ou se você preferir ver a fonte: https://codex.wordpress.org/Function_Reference/paginate_links

    Criador do tópico macielcaio15

    (@macielcaio15)

    Deslculpe Miguel Muller mas não entendi, o que devo substituir?

Visualizando 2 respostas - 1 até 2 (de um total de 2)
  • O tópico ‘Dúvida de loop com paginação’ está fechado para novas respostas.