• Resolved Roberto Godoy

    (@roberto-godoy)


    Pagination not working in custom query, in others works fine!

    <?php 
    
                                        global $wp_query;
                                        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                                        $wp_query->query( 'post_type=any&tag=' . get_query_var('tag') . '&paged='. $paged . '&posts_per_page=4');
                                ?>
    
                                <?php if (have_posts()) : ?>
    
                                        <?php 
    
                                            while ( have_posts() ) : the_post(); 
    
                                                $posttype = get_post_type();
    
                                                $content = '<div class="news-content">
                                                            <div class="news-content-left">
                                                                <div class="news-content-left-date sf-agencyfb">
                                                                    <span class="news-content-left-date-day">%s</span>
                                                                    <span class="news-content-left-date-month">%s</span>
                                                                </div>
                                                                <div class="news-content-left-socialshare">
                                                                    %s
                                                                </div>
                                                            </div>
                                                            <div class="news-content-right">
                                                                <h2>
                                                                    <a href="%s" rel="bookmark" title="Leia completo: %s">
                                                                        %s
                                                                    </a>
                                                                </h2>
                                                                %s
                                                                <p class="' . ($posttype == 'instrutores' ? 'instrutores-text' : 'news-content-right-text') . '">
                                                                    <a href="%s" rel="bookmark" title="Leia completo: %s">
                                                                        %s
                                                                    </a>
                                                                </p>
                                                                ' . ($posttype == 'instrutores' ? '<div class="gid-clear"></div>' : '') . '
                                                                <div class="news-content-right-cats gf-ubuntu">
                                                                    %s: %s
                                                                </div>
                                                                <div class="news-content-right-tags gf-ubuntu">
                                                                    %s: %s
                                                                </div>
                                                            </div>
                                                     </div>';
    
                                                $day        = get_the_time('d');
                                                $month      = get_the_time('M');
                                                $socials    = st_makeEntries();
                                                $url        = get_permalink();
                                                $title      = get_the_title();
                                                $image      = wp_get_attachment_image_src(get_post_thumbnail_id(), 'fullimage');
                                                $text       = excerpt(get_the_content(), 60);
                                                $cats       = get_category_string('link');
                                                $tags       = get_tags_string('link');
                                                $catsCount  =  count(explode(',', $cats));
                                                $tagsCount  =  count(explode(',', $tags));
    
                                                $image_div = '';
    
                                                if($image[0] != ''):
                                                    $image_div  = '<div class="' . ($posttype == 'instrutores' ? 'instrutores-thumb' : 'news-content-right-thumb') . '">
                                                                    <a href="' . $url . '" rel="bookmark" title="' . $title . '">
                                                                        <img src="' . $image[0] . '" alt="' . $title . '">
                                                                    </a>
                                                               </div>';
                                                endif;
    
                                                vprintf($content, array($day, $month, $socials, $url, $title, $title, $image_div, $url, $title, $text, 'Categoria' . ( $catsCount >= 2 ? 's' : ''), $cats,  'Tag' . ( $tagsCount >= 2 ? 's' : ''), $tags));
                                                echo '<div class="content-left-sepline"></div>';
    
                                            endwhile; 
    
                                        ?>
                                <?php endif; ?>
    
                                <?php
                                    wp_pagenavi();
                                ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pagination not Found – Help me and Tnks!’ is closed to new replies.