transform template code from page to category
-
Hi,
I’m currently using the current template:<?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(); ?>Its used in a page as a custom template.
I want to transform it to be used on the category template.
Here i call the category name : ‘cat’ => ’61’,
so it shows the posts title.How could it be possible to determine the value of ‘cat’ in this template when surfing on http://../?cat=value
Thx!
The topic ‘transform template code from page to category’ is closed to new replies.