wordpress category list sorting custom

PHP

$args = array(
          'orderby' => 'title',
          'order' => 'ASC'
        );
        $categories = get_categories($args);
        usort($categories, function($a, $b) {
           return get_field("category_order", "category_".$a->term_id) - get_field("category_order", "category_".$b->term_id);
        });
        foreach($categories as $category) {
          echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf(     __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name . '</a>' . ' ' . '(' . $category->count . ')' . '</li> ';
        }

No Items Found.

Add Comment
Type in a Nick Name here
 
Page Views

This page has been viewed 64 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

โค๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ•น

Random Quote
Even if you fall on your face, you're still moving forward.
Victor Kiam