Create Custom Query
-
Great plugin, I’m wondering if there’s a way to customize the output of the directory plugin.
I’m wanting to group Listings alphabetically by their first alphabet. E.g.
A
Adam Guy
Andrea Swift
B
Betty White
Billy BobTo pull this off with normal WP posts I would do something like this:
<?php $args=array( 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page'=>-1, 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo 'Alphabetic index of all ' . count($my_query->posts) . ' posts'; while ($my_query->have_posts()) : $my_query->the_post(); $this_char = strtoupper(substr($post->post_title,0,1)); if ($this_char != $last_char) { $last_char = $this_char; echo '<h2>'.$last_char.'</h2>'; } ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <?php endwhile; } //if ($my_query) wp_reset_query(); // Restore global post data stomped by the_post(). ?>So the question is where would I make edits in the plugin for this? And can I do this in a way that’s not overwritten on updates?
Thanks.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Create Custom Query’ is closed to new replies.