Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //get all post IDs for posts beginning with cap B, in title order,
- //display posts
- $first_char = 'B';
- $postids=$wpdb->get_col($wpdb->prepare("
- SELECT ID
- FROM $wpdb->posts
- WHERE SUBSTR($wpdb->posts.post_title,1,1) = %s
- ORDER BY $wpdb->posts.post_title",$first_char));
- if ($postids) {
- $args=array(
- 'post__in' => $postids,
- 'post_type' => 'post',
- 'post_status' => 'publish',
- 'cat'=>13, //List posts only from category 13
- 'posts_per_page' => -1,
- 'caller_get_posts'=> 1
- );
- $my_query = null;
- $my_query = new WP_Query($args);
- if( $my_query->have_posts() ) {
- echo 'Posts that begin with '. $first_char;
- ?>
- <?php while ($my_query->have_posts()): $i++; if(($i % 2) == 0) : $my_query->the_post(); ?>
- <li><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
- <?php
- endif; endwhile;
- $i = 0;
- }
- wp_reset_query(); // Restore global post data stomped by the_post().
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement