<?php $temp_query = $wp_query; ?>
<?php query_posts('tag=sometag,anothertag&posts_per_page=10'); ?>

<?php while (have_posts()) : the_post(); ?>
  // print post here
<?php endwhile; ?>

<?php $wp_query = $temp_query; ?>

By using this simple wordpress loop, how do you show Just the posts (publish game titles really) beginning with say letter 'G'. I wish to sort posts alphabetically only individuals that suits, not every.


Crazy thought here, why dont you simply add the Letter like a Tag towards the publish. Quite simply, should you wanted your publish "The Gorgeous Trees" to appear under "B" (observe that I stated B and never T), apply the tag known as "B". Then in your soul query posts tag section, just make certain you append your letter of preference!

Is also easy to do for pages?

Look into the publish title within the loop:

while (have_posts()) : the_post();
    // jump to the next post if this one doesn't start with the letter you want
    if($post->post_title[0] != $letter) continue

    // do what you want with the post

I'd setup an action for that query. Inside your styles functions.php file:

add_action( 'posts_where', 'startswithaction' );
function startswithaction( $sql ){
    global $wpdb;
    $startswith = get_query_var( 'startswith' );

    if( $startswith ){
        $sql .= $wpdb->prepare( " AND $wpdb->posts.post_title LIKE %s ", $startswith.'%' );

    return $sql;

You'll be able to query the posts like so:

query_posts( 'startswith=G&posts_per_page=10' );