Customer wp_query pagination wordpress

Posted: April 4, 2015 in web
shortcode:

function sc_blogs($atts) {
        $a = shortcode_atts(array(
            'type' => '',
            'posts_per_page' => -1,
                ), $atts);
        $GLOBALS['wp_query']->max_num_pages = $a['posts_per_page'];
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        $custom_query = new WP_Query(array('posts_per_page' => $a['posts_per_page'], 'category_name' => $a['type'], 'paged' => $paged)); // exclude category 9
        while ($custom_query->have_posts()) : $custom_query->the_post();
            ?>
            <?php

            get_template_part('content', get_post_format());
            ?>

        <?php endwhile; ?>         

        <?php

        wp_reset_postdata(); // reset the query 
    }


template:

<section id="primary" class="content-area col-md-9">
    <main id="main" class="site-main" role="main">
        <?php while (have_posts()) : the_post(); ?>
            <?php the_content(); ?>
        <?php endwhile; // end of the loop. ?>
        <?php
        nyehealth_paging_nav();   //added this 
        ?>
    </main><!-- #main -->
</section><!-- #primary -->




Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s