shutlar Posted December 16, 2012 Share Posted December 16, 2012 Hello,I am new to here and apologise if this is posted in the wrong section, I would like to set the order that categories load within this script, basically i would like to load category ID 14 then 4 then 13. I have pasted my code below, if anyone can assist I would greatly appreciate it as I am pretty useless with PHP modifications! The output is a box within a wordpress site see attached image: http://ajswebsites.c...t.jpg ignore the bit at the bottom about the read morenot working that was something else that has been fixed! Thanks in advance. Let me know how I buy whoever a beer <?php function tie_home_tabs(){ $home_tabs_active = tie_get_option('home_tabs_box'); $home_tabs = tie_get_option('home_tabs'); $Posts = 5; if( $home_tabs_active && $home_tabs ): ?> <div id="cats-tabs-box" class="cat-box-content clear cat-box"> <div class="cat-tabs-header"> <ul> <?php foreach ($home_tabs as $cat ) { ?> <li><a href="#catab<?php echo $cat; ?>"><?php echo get_the_category_by_ID($cat) ?></a></li> <?php } ?> </ul> </div> <?php foreach ($home_tabs as $cat ) { $count = 0; $cat_query = new WP_Query('cat='.$cat.'&posts_per_page='.$Posts); ?> <div id="catab<?php echo $cat; ?>" class="cat-tabs-wrap"> <?php if($cat_query->have_posts()): ?> <ul> <?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?> <?php if($count == 1) : ?> <li class="first-news"> <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?> <div class="post-thumbnail"> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"> <?php tie_thumb('',272,125); ?> <span class="overlay-icon"></span> </a> </div><!-- post-thumbnail /--> <?php endif; ?> <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <p class="post-meta"> <?php tie_get_score(); ?> <?php the_time(get_option('date_format')); ?> <?php comments_popup_link( __( 'Leave a comment', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?> </p> <div class="entry"> <?php tie_excerpt_home() ?> <a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More »', 'tie' ) ?></a> </div> </li><!-- .first-news --> <?php else: ?> <li> <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?> <div class="post-thumbnail"> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb('',60,50); ?></a> </div><!-- post-thumbnail /--> <?php endif; ?> <h3><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3> <p class="post-meta"> <?php the_time(get_option('date_format')); ?> <?php comments_popup_link( __( 'Leave a comment', 'tie' ), __( '1 Comment', 'tie' ), __( '% Comments', 'tie' ) ); ?> <?php tie_get_score(); ?> </p> </li> <?php endif; ?> <?php endwhile;?> </ul> <div class="clear"></div> <?php endif; ?> </div> <?php } ?> </div><!-- #cats-tabs-box /--> <?php endif; } ?> Link to comment https://forums.phpfreaks.com/topic/272070-get-category-by-id-fix-the-order/ Share on other sites More sharing options...
Muddy_Funster Posted December 17, 2012 Share Posted December 17, 2012 Please use code or php tags when posting code, Thats a nightmare to read - I can't even see where you declare your get_the_category_by_id() function Link to comment https://forums.phpfreaks.com/topic/272070-get-category-by-id-fix-the-order/#findComment-1399742 Share on other sites More sharing options...
shutlar Posted December 17, 2012 Author Share Posted December 17, 2012 </ul>have_posts()): ?> have_posts() ) : $cat_query->the_post(); $count ++ ;?> [b] [/b] [url=<?php%20the_permalink()%20?>][/url] [b] [/b] </p> Link to comment https://forums.phpfreaks.com/topic/272070-get-category-by-id-fix-the-order/#findComment-1399773 Share on other sites More sharing options...
shutlar Posted December 17, 2012 Author Share Posted December 17, 2012 Sorry i tried code but looks blank? I have also attached, sorry for mess!!! how about: </ul>have_posts()): ?> have_posts() ) : $cat_query->the_post(); $count ++ ;?> [b] [/b] [b] [/b] </p>home-cat-tabs.rtf Link to comment https://forums.phpfreaks.com/topic/272070-get-category-by-id-fix-the-order/#findComment-1399774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.