Revisions
- January 22, 2013 @ 02:29:12 [Current Revision] by PeterLugg
- January 22, 2013 @ 02:25:48 by PeterLugg
Revision Differences
January 22, 2013 @ 02:25:48 | Current Revision | ||
---|---|---|---|
Content | |||
Added: I know of no plugin that does this. | |||
Added: However, some custom coding displaying every letter regardless of having posts or not: <a href="http:// wordpress.pastebin.com/f524c9f4" rel="nofollow" >http://wordpress.pastebin.com/ f524c9f4</a> | |||
Added: [php]<?php | |||
Added: // Reference: http://wordpress.org/ support/topic/148727 | |||
Added: $posts = new WP_Query(" cat=$cat& orderby=title& order=ASC& showposts=-1"); | |||
Added: if ($posts->have_posts()) : | |||
Added: for($i='A';$i!='AA';$i++) : | |||
Added: ?> | |||
Added: <h3 id="<?php echo $i; ?>"> </a><?php echo $i; ?></h3> | |||
Added: <ul> | |||
Added: <?php | |||
Added: while ($posts->have_posts()) : | |||
Added: $posts->the_post(); | |||
Added: if( $i == strtoupper(trim( substr($post- >post_title, 0, 1))) ) : | |||
Added: ?> | |||
Added: <li><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li> | |||
Added: <?php | |||
Added: endif; | |||
Added: endwhile; | |||
Added: ?> | |||
Added: </ul> | |||
Added: <?php | |||
Added: endfor; | |||
Added: endif; | |||
Added: ?>[/php] | |||
Added: Version that only displays letter heading when one or more posts fall under it: <a href="http:// wordpress.pastebin.com/f2302b7cb" rel="nofollow" >http://wordpress.pastebin.com/ f2302b7cb</a> | |||
Added: [php]<?php | |||
Added: // Reference: http://wordpress.org/ support/topic/148727 | |||
Added: $posts = new WP_Query(" cat=$cat& orderby=title& order=ASC& showposts=-1"); | |||
Added: if ($posts->have_posts()) : | |||
Added: for($i='A';$i!='AA';$i++) : | |||
Added: ?> | |||
Added: <?php | |||
Added: while ($posts->have_posts()) : | |||
Added: $posts->the_post(); | |||
Added: if( $i == strtoupper(trim( substr($post- >post_title, 0, 1))) ) : | |||
Added: if( !$a_z_header ) : | |||
Added: $a_z_header = 1; | |||
Added: ?> | |||
Added: <h3 id="<?php echo $i; ?>"> </a><?php echo $i; ?></h3> | |||
Added: <ul> | |||
Added: <?php | |||
Added: endif; | |||
Added: ?> | |||
Added: <li><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li> | |||
Added: <?php | |||
Added: endif; | |||
Added: endwhile; | |||
Added: ?> | |||
Added: </ul> | |||
Added: <?php | |||
Added: $a_z_header = 0; | |||
Added: endfor; | |||
Added: endif; | |||
Added: ?>[/php] | |||
Added: Or try this: | |||
Added: [php]<?php | |||
Added: $args = array( | |||
Added: 'orderby' => 'title', | |||
Added: 'order' => 'ASC', | |||
Added: 'caller_get_posts' => 1, | |||
Added: 'posts_per_page' => 20, | |||
Added: ); | |||
Added: query_posts($args); | |||
Added: if (have_posts()) { | |||
Added: $curr_letter = ''; | |||
Added: while (have_posts()) { | |||
Added: the_post(); | |||
Added: $this_letter = strtoupper(substr( $post->post_ title,0,1)); | |||
Added: if ($this_letter != $curr_letter) { | |||
Added: echo "<h2> # $this_letter #</h2>"; | |||
Added: $curr_letter = $this_letter; | |||
Added: } | |||
Added: ?> | |||
Added: <br /> | |||
Added: <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> | |||
Added: <?php } | |||
Deleted: | Added: } | ||
Added: ?>[/php] |
Note: Spaces may be added to comparison text to allow better line wrapping.
No comments yet.