• knoxious

    (@knoxious)


    Hi Guys i’m having a bit of a problem here as i’m not well versed in PHP and CSS. The categories are not the order i want them. They are sorted out in alphabetical order which i do not want.

    The categories.php codes are as below:

    <!-- begin categories -->
    		<!-- Category Nav Starts -->
    			<div id="cat_navi" class="wrap">
    				<ul id="secnav">
    
    					<?php if (get_option('pov_home_link')) : ?>
    
    					<?php endif; ?>
    
    					<?php foreach ( (get_categories('exclude='.get_option('pov_cat_ex') ) ) as $category ) { if ( $category->category_parent == '0' ) { ?>
    
                        <li>
                            <a href="<?php echo get_category_link($category->cat_ID); ?>"><?php echo $category->cat_name; ?></a>
    
                            <?php if (get_category_children($category->cat_ID) ) { ?>
                            <ul><?php wp_list_categories('title_li&child_of=' . $category->cat_ID ); ?></ul>
                            <?php } ?>
                        </li>
    
    					<?php } } ?>
    
    				</ul>
    			</div>
    			<!-- Category Nav Ends -->
    		<!-- end categories -->
    	<div style="clear: both;"></div>

    If i’m not wrong, the code i should be looking for would be:
    <?php wp_list_categories('title_li&child_of=' . $category->cat_ID ); ?>

    I’ve tried changing that to:
    <?php wp_list_categories('orderby=name&include=3,5,9,16'); ?>

    The numbers represent my cat ID but when i save changes, the categories are still in the default sorted by alphabetical order. I appreciate if anyone could help me out ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter knoxious

    (@knoxious)

    hi nebulus thanks for the reply. I changed to the code below but still don’t get it right.

    <?php wp_list_categories('orderby=cat_ID&include=3,22,15,1'); ?>

    I think i’ve done it wrong?

    orderby=id, not cat_ID

    you can order by id, name, slug, count or term_group

    Thread Starter knoxious

    (@knoxious)

    yeah i tried that too but it doesn’t work..

    It should. But okay, I guess you could always mess around with get_categories.

    I am guessing that what you want is to retrieve categories 1,3,15 and 22, but process them in order 3,22,15,1. Here is one way to do that:

    $cats = get_categories('include=1,3,15,22');
    foreach ($cats as $cat) {
       $catsbyid[$cat->cat_ID] = $cat;
    }
    foreach (array(3,22,15,1) as $i) {
       $category = $catsbyid[$i];
       if ($category) {
           // Process this category
       }
    }

    You should try using a free plugin called “Category Order”. Install the plugin and go under “Posts” and you can re-arrange your categories using drag and drop.

    To get the plugin, just type “Category Order” in the search field within your WordPress admin.

    Please let me know if this helps.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Categories Not In Order’ is closed to new replies.