Change Portolio Display Order
-
Hello,
I have some code that displays portolio categories on my site in what looks like alphabetical order. I would like to change it to display the categories in a particular order using ID number. Can anyone help me accomplish this looking at the code?
<?php get_header(); ?> <!-- MAIN CONTENT --> <div id="outermain" class="inner"> <div class="container"> <section id="maincontent" class="twelve columns"> <?php get_template_part( 'title'); ?> <div id="ts-display-portfolio"> <?php $cats = of_get_option('templatesquare_pf_category' ,''); $disabletitle = of_get_option('templatesquare_pf_disable_title' ,'false'); $disabledesc = of_get_option('templatesquare_pf_disable_desc' ,'false'); $longdesc = of_get_option('templatesquare_pf_lengthchar' ,''); $categories = $cats; $sideoutput = ""; foreach ($categories as $key => $value) { if($value==1){ $catflag = 1; break; } } if(isset($catflag)){ $sideoutput .= '<ul id="filter" class="controlnav">'; $sideoutput .= '<li class="segment-1 selected-1"><a href="#" data-value="all">'.__('All Categories','templatesquare').'</a></li>'; foreach ($categories as $key => $value) { if(!$value) continue; $catname = get_term($key,"pcategory"); $sideoutput .= '<li class="segment-1"><a href="#" data-value="'.$key.'">'.$catname->name.'</a></li>'; } $sideoutput .= '</ul>'; }else{ $sideoutput .='<span style="color:red">Please Setting Portfolio in Appearance->Theme Options->Portfolio.</span>'; } echo $sideoutput; ?> <ul id="ts-display-pf-filterable" class="ts-display-pf-col-4 image-grid"> <?php $idnum = 1; $arrID = array(); foreach ($categories as $key => $value) { if(!$value) continue; $catname = get_term($key,"pcategory"); $catinclude = 'pcategory='. $catname->slug ; query_posts($catinclude .' &post_type=pdetail&showposts=-1&orderby=date&paged='.$paged); while ( have_posts() ) : the_post(); $custom = get_post_custom($post->ID); $cf_thumb = (isset($custom["thumb"][0]))? $custom["thumb"][0] : ""; $cf_lightbox = (isset($custom["lightbox"][0]))? $custom["lightbox"][0] : ""; $cf_externallink = (isset($custom["external-link"][0]))? $custom["external-link"][0] : ""; //get post-thumbnail attachment $attachments = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'order' => '', 'post_mime_type' => 'image') ); foreach ( $attachments as $att_id => $attachment ) { $getimage = wp_get_attachment_image_src($att_id, 'post-col4', true); $portfolioimage = $getimage[0]; $cf_thumb2 ='<img src="'.$portfolioimage.'" alt="" class="scale-with-grid" />'; } //thumb image if($cf_thumb!=""){ $cf_thumb = "<img src='" . $cf_thumb . "' alt='' class='scale-with-grid' />"; }elseif(has_post_thumbnail($post->ID)){ $cf_thumb = get_the_post_thumbnail($post->ID, 'post-col4', array('class' => 'scale-with-grid','alt' =>'', 'title' =>'')); }else{ $cf_thumb = $cf_thumb2; } //fade action if($cf_lightbox!=""){ $golink = $cf_lightbox; $rollover = "rollover"; $rel = " data-rel=prettyPhoto[".$catname->slug."]"; }elseif($cf_externallink!=""){ $golink = $cf_externallink; $rollover = "rollover gotolink"; $rel = ""; }else{ $golink = get_permalink(); $rollover = "rollover gotopost"; $rel = ""; } $ids = get_the_ID(); $cats = ts_portfolio_getcategoryids($ids); $classpf = ""; foreach($cats as $cat){ $classpf .= $cat["term_id"]." "; } if(($idnum%4) == 0){$classpf .= "nomargin ";} if($disabletitle==true && $disabledesc==true){$classpf .= " no-pf-text";}else{$classpf .="";} if(!in_array($ids,$arrID)){ ?> <li data-id="id-<?php echo $idnum; ?>" class="<?php echo $key.' '.$classpf;?>"> <?php $output=""; if($cf_thumb!=""){ $output.='<div class="ts-display-pf-img">'; $output .='<a class="image" href="'.$golink.'" '.$rel.' title="'.get_the_title().'">'; $output .='<span class="'.$rollover.'"></span>'; $output .=$cf_thumb; $output .='</a>'; $output.='</div>'; $output.='<span class="shadowpfimg"></span>'; } $output.='<div class="ts-display-pf-text">'; if($disabletitle!=true){ $output .='<h2><a href="'.get_permalink().'">'.get_the_title().'</a></h2>'; } if($disabledesc!=true){ $excerpt = get_the_excerpt(); $output .='<span>'.ts_string_limit_char($excerpt,$longdesc).'</span>'; } $output.='</div>'; echo $output; ?> </li> <?php $idnum++; $classpf=""; $arrID[] = $ids; } endwhile; // End the loop. Whew. wp_reset_query(); } ?> </ul> </div> <div class="clear"></div><!-- clear float --> </section><!-- maincontent --> </div> </div> <!-- END MAIN CONTENT --> <?php get_footer(); ?>
- The topic ‘Change Portolio Display Order’ is closed to new replies.