Created
January 18, 2015 19:02
-
-
Save shahadat014/a6c38be48a2062b272bd to your computer and use it in GitHub Desktop.
Custom post query with pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $temp = $wp_query; | |
| $wp_query = null; | |
| $wp_query = new WP_Query(); | |
| $wp_query->query('showposts=6&post_type=posttype&orderby=menu_order&order=ASC'.'&paged='.$paged); | |
| while ($wp_query->have_posts()) : $wp_query->the_post(); | |
| ?> | |
| <?php | |
| $custom_field= get_post_meta($post->ID, 'custom_field', true); | |
| ?> | |
| <h2><?php the_title(); ?></h2> | |
| <?php the_content(); ?> | |
| <p><?php echo $custom_field; ?></p> | |
| <?php endwhile; ?> | |
| <?php if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else { include('navigation.php'); } ?> | |
| <?php | |
| $wp_query = null; | |
| $wp_query = $temp; // Reset | |
| ?> | |
| Navigation.php code is | |
| <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyeleven' ) ); ?></div> | |
| <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment