Jump to content

Recommended Posts

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;

}

?>

post-135082-0-39782000-1355700087_thumb.png

Edited by shutlar
Link to comment
https://forums.phpfreaks.com/topic/272070-get-category-by-id-fix-the-order/
Share on other sites

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

Edited by shutlar
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.