Title: make sort by posts possible
Last modified: August 21, 2016

---

# make sort by posts possible

 *  [sayagdan](https://wordpress.org/support/users/sayagdan/)
 * (@sayagdan)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/make-sort-by-posts-possible/)
 * Hi,
    you could improve it by adding posts viewing function. I tried to modify
   the code, using get_post indead of get_pages but then the foreach function made
   the program crash.
 * Why stop with categories and pages?
    Make the posts!
 * (please 🙂 )
 * [http://wordpress.org/extend/plugins/multi-column-tag-map/](http://wordpress.org/extend/plugins/multi-column-tag-map/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [tugbucket](https://wordpress.org/support/users/tugbucket/)
 * (@tugbucket)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/make-sort-by-posts-possible/#post-3906581)
 * [http://www.dynamicwp.net/articles-and-tutorials/how-to-group-articles-or-posts-alphabetically/](http://www.dynamicwp.net/articles-and-tutorials/how-to-group-articles-or-posts-alphabetically/)
 *  Thread Starter [sayagdan](https://wordpress.org/support/users/sayagdan/)
 * (@sayagdan)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/make-sort-by-posts-possible/#post-3906598)
 * thank you,
    ive been working all day to make a template that would look like 
   your plugin.. in vain… anyway// definetly, your plugin would be shiny with this
   function..
 *  Thread Starter [sayagdan](https://wordpress.org/support/users/sayagdan/)
 * (@sayagdan)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/make-sort-by-posts-possible/#post-3906606)
 * finally i did this :
 *     ```
       <?php
       /**
        * Template Name: Include arbo
        *
        * This is the template that displays all pages by default.
        * Please note that this is the WordPress construct of pages
        * and that other 'pages' on your WordPress site will use a
        * different template.
        *
        * @package WordPress
        * @subpackage Twenty_Twelve
        * @since Twenty Twelve 1.0
        * // <?php get_sidebar(); ?>
        */
   
       get_header();
       	?><ul id="extra-sidebar-lt" class="widget-area" role="complementary">
       <?php dynamic_sidebar( 'sidebar-4' ); ?>
       </ul><?php 
   
       $args=array(
         'cat' => '61',
         'orderby' => 'title',
         'order' => 'ASC',
         'posts_per_page'=>-1,
         'caller_get_posts'=>1
       );
       $my_query = new WP_Query($args);
   
       if( $my_query->have_posts() ) {
   
       	if
       	 ($my_query->have_posts()) : $my_query->the_post();
        ?><div id="lt-title"><?php
       $categories = get_the_category();
       $separator = ' ';
       $output = '';
       if($categories){
       	foreach($categories as $category) {
       		$output .= '<a href="" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
       	}
       echo trim($output, $separator);
       }
       ?></div><?php
   
       endif;
       ?><div id="lt" class="LTclass"><?php
        while 
   
        ($my_query->have_posts()) : $my_query->the_post();
           $this_char = strtoupper(substr($post->post_title,0,1));
   
         if ($this_char != $last_char) {
              $last_ord = ord($last_char);
              while ( $last_char >= 'A' && (ord($this_char) - $last_ord) > 1) {
                 ++$last_ord;
                 $last_char = chr($last_ord);
   
       		  echo '<div id="lettra"><a name="'.$last_char.'"></a></div>';
   
              }
              $last_char = $this_char;
             echo '<a name="'.$last_char.'"></a><div id="lettra">'.$last_char.'</div>';
           } ?>
           <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br/>
           					<?php echo get_post_meta($post->ID, 'description', true); ?>
   
           </p>
           <?php
         endwhile;
       }
       ?></div><?php
   
       wp_reset_query();
       get_footer();
       ?>
       ```
   
 * but i have to call a unique category and make a template for each page. Could
   it be possible to adapt this template for category section and get the category
   from the current ?cat= ?
    thx
 *  Plugin Author [tugbucket](https://wordpress.org/support/users/tugbucket/)
 * (@tugbucket)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/make-sort-by-posts-possible/#post-3906610)
 * If your variable is the ID:
 *     ```
       change:
       'cat' => '61',
       to:
       'cat' => $_REQUEST['cat'],
       ```
   
 * [http://www.w3schools.com/php/php_post.asp](http://www.w3schools.com/php/php_post.asp)
 * If your variable is the category name:
 *     ```
       $category_id = get_cat_ID($_REQUEST['cat']);
       'cat' => $_REQUEST[$category_id],
       ```
   
 * [http://codex.wordpress.org/Function_Reference/get_cat_ID](http://codex.wordpress.org/Function_Reference/get_cat_ID)
 * *Note: all untested but looks right

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘make sort by posts possible’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/multi-column-tag-map_9e2525.svg)
 * [Multi-column Tag Map](https://wordpress.org/plugins/multi-column-tag-map/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/multi-column-tag-map/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/multi-column-tag-map/)
 * [Active Topics](https://wordpress.org/support/plugin/multi-column-tag-map/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multi-column-tag-map/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multi-column-tag-map/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [tugbucket](https://wordpress.org/support/users/tugbucket/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/make-sort-by-posts-possible/#post-3906610)
 * Status: not resolved