Support » Fixing WordPress » link to display new to old and old to new categories

  • Resolved Kevin Kwok



    basically my index page displays posts and categories, and organizes posts by categories see code here:

    by default my code shows categories in ASC order from low to high (aka old to new) categories, however if you look at my site on the right column I want to have a link to sort by low to high and high to low.

    I can link low to high just to display the index page like normal since its already in ASC order. but how do i display DSC order and link to it?

Viewing 1 replies (of 1 total)
  • solved myself.

    		$sortby = 'DESC';
    	$cat_args = array(
    					  	'orderby' => 'ID',
    						'order' => $_GET[sortby]	// New Code
    	$categories = get_categories($cat_args);
    	foreach($categories as $category)
    		echo '<div>';
    		echo '<div style="float: right; position:absolute; padding-left:690px; padding-right:10px; font-family:Courier New; font-size:16px; width:180px;">
    		<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "" )) . '" ' . '>' . $category->name. ' '.$category->description.'</a></div>';
    		$args = array(
    					  	'orderby' => 'ID',
    						'order' => 'DESC',
    						'showposts' => -1,
    						'category' => $category->term_id,
    						'caller_get_posts' => 1
    		$posts = get_posts($args);
    		echo '<div style="float: left; width: 660px;">';
    		foreach($posts as $post)
    			echo "<a href=\"".$post->guid."\" rel=\"bookmark\">";
    			echo '<div style="float: left; width: 150px; margin-right: 15px;">';
    			if(get_post_meta($post->ID, 'full-image', $single = true))
    				echo '<img class="full-image" src="'.get_post_meta($post->ID, 'full-image', $single = true).'" width="150" height="113" /><BR />';
    				echo '<img class="full-image" src="'.bloginfo('url').'" width="150" height="113" /><BR />';
    				echo '<div style="height:50px;">
    						<div style="float: left; margin-top:6px;">'.get_post_meta($post->ID, 'designed-by', $single = true).'</div>
    						<div style="float: right; margin-top:6px;">'.$post->post_title.'</div>
    						<div style="clear: both;"></div>
    			echo '</div>';
    			echo '</a>';
    		echo '</div>';
    		echo '</div>';

Viewing 1 replies (of 1 total)
  • The topic ‘link to display new to old and old to new categories’ is closed to new replies.