Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function post_list_shortcode($atts){
- extract( shortcode_atts( array(
- 'count' => '',
- ), $atts) );
- $q = new WP_Query(
- array('posts_per_page' => $count, 'post_type' => 'posttype', 'orderby' => 'menu_order','order' => 'ASC')
- );
- $list = '<div class="custom_post_list">';
- while($q->have_posts()) : $q->the_post();
- $idd = get_the_ID();
- $custom_field = get_post_meta($idd, 'custom_field', true);
- $post_content = get_the_content();
- $list .= '
- <div class="single_post_item">
- <h2>' .do_shortcode( get_the_title() ). '</h2>
- '.wpautop( $post_content ).'
- <p>'.$custom_field.'</p>
- </div>
- ';
- endwhile;
- $list.= '</div>';
- wp_reset_query();
- return $list;
- }
- add_shortcode('post_list', 'post_list_shortcode');
- -----------------------------==========================
- <?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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement