Access our premium support and let us know your problems, we will help you solve them.

0
No products in the cart.

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: pagination on custom post wp_query #9513
    blanksuraj-singh
    Participant
    <?php    
    add_shortcode('show_all_news', 'show_all_news');
        function show_all_news($atts) {
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            $limit = 4;
            $offset = ( $limit * $paged ) - $limit;
            $atts['pages'] = $paged; 
            $atts['post-type'] = 'your_custom_post_type'; 
            $atts['orderby'] = 'date'; 
            $atts['order'] = 'DESC';
            $atts['offset'] = $offset; 
            $atts['posts_per_page'] = $limit; 
            $atts['caller_get_posts'] = 1; 
    
            $result = new WP_Query($atts);
            echo '<div class="news-cont">';  
            if($result->have_posts())
            {
                while ($result->have_posts()) : $result->the_post(); 
                    echo '<div class="bg-white news-block">'; 
                    echo '<em class="date">'. get_the_date().'</em>' ?>
    
                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                    <?php 
                    echo "<p>";
                    the_excerpt(); 
                    echo "</p>";
                    echo '</div>';
                endwhile;
    
                ?>
                    <ul class="pagination" style="width:100%;">
                        <li id="previous-posts" style="float:left">
                            <?php previous_posts_link( '<< Vorige Pagina', $result->max_num_pages ); ?>
                        </li>
                        <li id="next-posts" style="float:right">
                            <?php next_posts_link( 'Volgende Pagina >>', $result->max_num_pages ); ?>
                        </li>
                    </ul>
                <?php 
    
            }
            echo '</div>'; 
            wp_reset_query();
        }
    
Viewing 1 post (of 1 total)