Forums

[resolved] help with the categories order (21 posts)

  1. amitrozen
    Member
    Posted 3 years ago #

    Hey.
    My name is amit and i need help to order the categories in my site.
    i'm useing arthemia premium theme and want to order the categories in the middle.

    this is the dome site: http://demo.colorlabsproject.com/arthemia/

    the categories order by ABC and i want to order them by ID.

    this is the code for the middle:

    <div id="middle" class="clearfloat">
    
    	<?php $postcat = get_settings( "ar_categories" );
    		if( $ar_categories == 0 ) { $ar_categories= $cp_categories->cat_ID; }
    
    	if( ! is_array( $postcat ) ) {
    		foreach ( $cp_categories as $b ) {
    		$postcat[] = $b->cat_ID;
    		}
    	}
    
    	$postcat = array_slice($postcat, 0, 5);
    
    	foreach ($postcat as $cp_pC ) { ?>
    
    	<?php query_posts("showposts=1&cat=$cp_pC&orderby=ID");?>
    	<div id="cat-<?php echo $cp_pC; ?>" class="category" onclick="window.location.href='<?php echo get_category_link($cp_pC);?>';">
    		<span class="cat_title"><?php single_cat_title(); ?></span>
    		<p><?php echo category_description($cp_pC); ?></p>
    	</div>
    	<?php } ?>
    
    	<?php wp_reset_query(); ?>
        </div>

    please help me.
    it's very importent for me.

    tnx.

  2. nerdanita
    Member
    Posted 3 years ago #

    Did you try this plugin?
    Category Order
    It allow you to order the categories the way you want.
    It's not the same you're doing, but can help.

  3. amitrozen
    Member
    Posted 3 years ago #

    Yes i try... not working

  4. amitrozen
    Member
    Posted 3 years ago #

    Please help me to fix this.
    i will give 3 links from my sites for this help.

    tnx.

  5. amitrozen
    Member
    Posted 2 years ago #

    please? help.

  6. amitrozen
    Member
    Posted 2 years ago #

    help me please.

  7. amitrozen
    Member
    Posted 2 years ago #

    nobody know what to do? please its very importent for me.

  8. kapiljain.in
    Member
    Posted 2 years ago #

    Hi amitrozen,

    You can do it by retrieving categories using custom query. This article might help you:

    http://www.devlounge.net/general/last-updated-categories-wordpress-23-query

  9. amitrozen
    Member
    Posted 2 years ago #

    This article does not help me.
    Can anyone help?

  10. kapiljain.in
    Member
    Posted 2 years ago #

    Hi,

    Use the following code to display categories order by ID

    <div id="middle" class="clearfloat">
    	<?php
    		global $wpdb;
    		$query = "select t.term_id, t.name, t.slug, tx.description as catDes from $wpdb->terms t, $wpdb->term_taxonomy tx where t.term_id = tx.term_id and tx.taxonomy = 'category' order by t.term_id";
    		$results = $wpdb->get_results($query);
    		foreach ($results as $result) {
    			$catPermalink = get_bloginfo('url') . "/category/" . $result->slug . "/";
    			?>
    				<div id="cat-<?php echo $result->id; ?>" class="category" onclick="window.location.href='<?php echo $catPermalink;?>';">
    					<span class="cat_title"><?php echo $result->name ?></span>
    					<p><?php echo $result->catDes;?></p>
    				</div>
    			<?php
    		}
    	?>
    </div>
  11. amitrozen
    Member
    Posted 2 years ago #

    its work good. its order the categories but whet i use the theme color option in the admin panel its now work to change the colors.

    last line: not working.

    you have any idea what i need to do?

  12. amitrozen
    Member
    Posted 2 years ago #

    admin panel its *not* work to change the colors

  13. kapiljain.in
    Member
    Posted 2 years ago #

    I think this is a typo mistake.

    Replace <?php echo $result->id; ?> with <?php echo $result->term_id; ?> in line # 9

    Hope it works for you.

    Thanks

  14. amitrozen
    Member
    Posted 2 years ago #

    not working :(

  15. amitrozen
    Member
    Posted 2 years ago #

    i think we need to edot the code i post here in the first and to edit or to add order commands.

    please help me to finish with this... tnx

  16. kapiljain.in
    Member
    Posted 2 years ago #

    Hi amitrozen,

    This is a premium theme and I don't have access to the theme pages.

    If your share the theme with me I will try to resolve this issue.

    You may send it at kapil.email@yahoo.com or me@kapiljain.in

    Thanks
    Kapil Jain

  17. amitrozen
    Member
    Posted 2 years ago #

    I finish to send you the theme. please help me its very importent for me.
    tnx.

  18. kapiljain.in
    Member
    Posted 2 years ago #

    Hi,

    Theme developer use get_categories() function of wordpress for list categories in this theme.

    By default this function display list of categories order by name. You can change it by adding a parameter get_categories() function as get_categories('orderby=ID').

    For more details of this function go to http://codex.wordpress.org/Function_Reference/get_categories

    I found get_categories() function following pages:

    1. header.php
    2. sidebar.php
    3. functions.php
    4. index.php

    Replace get_categories('hide_empty=0') with get_categories('hide_empty=0&orderby=ID') in above mentioned pages where you want to change order of categories.

    Hope now it works fine for you.

    Note: please take a backup before making any changes.

    Also replied over mail.
    Thanks
    Kapil Jain

  19. amitrozen
    Member
    Posted 2 years ago #

    Tnx. I try this and its not working... the categories stay by names... its work for you? what i need to do?

  20. kapiljain.in
    Member
    Posted 2 years ago #

    Its works fine for me.

    Sent updated pages via email.

  21. blackhell
    Member
    Posted 2 years ago #

    hi kapiljain.in
    I have seen your last two posts and I also need some help with this code,
    can you send me the updated code pages also please??
    my email is:franxiscoflores@gmail.com

    Thank You

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags