Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author tugbucket

    (@tugbucket)

    Thread Starter sayagdan

    (@sayagdan)

    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

    (@sayagdan)

    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

    (@tugbucket)

    If your variable is the ID:

    change:
    'cat' => '61',
    to:
    'cat' => $_REQUEST['cat'],

    https://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],

    https://codex.www.ads-software.com/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.