WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Images
[resolved] Doesn't adhere to 'orderby' argument (7 posts)

  1. robalan
    Member
    Posted 1 year ago #

    I'm trying to sort the taxonomy but Taxonomy Images isn't playing nice. This works:

    $terms = get_terms( 'work_cat', $args );

    but this doesn't:

    $terms = apply_filters( 'taxonomy-images-get-terms', '', $args );

    Any ideas? Here's the full query:

    <?php
    	$args = array(
    		'taxonomy'     => 'work_cat',
    		'orderby'      => 'id',
    		'order'        => 'ASC',
    		'hierarchical' => 1,
    	);
    
    	$terms = apply_filters( 'taxonomy-images-get-terms', '', $args );
    
    	$i = 0;
    	$len = count($categories);
    	foreach ($terms as $term) {
    	?>
    		<div class="fourcol <?php if ($i == 0): ?> first<?php elseif ($i == $len - 1): ?> last<?php endif; ?>">
    		<a href="<?php echo get_term_link($term->slug, 'work_cat'); ?>"><?php echo wp_get_attachment_image( $term->image_id, 'full' ); ?></a>
    		<h2><?php echo $term->name; ?></h2>
    		<p><?php echo $term->description; ?></p>
    		<a href="<?php echo get_term_link($term->slug, 'work_cat'); ?>">See More &raquo;</a></div>
    
    	<?php $i++;
    	}
    ?>

    http://wordpress.org/extend/plugins/taxonomy-images/

  2. Michael Fields
    Themer
    Plugin Author

    Posted 1 year ago #

    The formatting of the $args array looks incorect. Maybe try:

    $args = array(
    	'taxonomy'     => 'work_cat',
    	'term_args'    => array(
    		'orderby'      => 'id',
    		'order'        => 'ASC',
    		'hierarchical' => 1,
    	),
    );
  3. robalan
    Member
    Posted 1 year ago #

    Michael,

    That was it—thank you! And it was pointed out on StackExchange that term_args is part of the plugin's functionality: http://wordpress.org/extend/plugins/taxonomy-images/ - which I had missed.

    Cheers!

  4. Michael Fields
    Themer
    Plugin Author

    Posted 1 year ago #

    Sweet! Glad I could help! There is documentation on the plugin page - but not in a copy-paste code example. Best thing to do is read the public-filters.php file in the plugin itself: http://plugins.trac.wordpress.org/browser/taxonomy-images/trunk/public-filters.php

  5. yuccav2
    Member
    Posted 1 year ago #

    Hello. Nice.
    But that don't work for me with name :
    $args = array(
    'taxonomy' => 'type-produit',
    'term_args' => array(
    'orderby' => 'name',
    'order' => 'ASC',
    'hierarchical' => 1
    )
    );
    $terms = apply_filters( 'taxonomy-images-get-terms', '', $args );

  6. yuccav2
    Member
    Posted 1 year ago #

    I find this to add, and that do it :
    function sortStdArray($cats,$index){
    $sort=array();
    $return=array();
    for ($i=0; isset($cats[$i]); $i++)
    $sort[$i]= $cats[$i]->{$index};
    natcasesort($sort);
    foreach($sort as $k=>$v)
    $return[]=$cats[$k];
    return $return;
    }
    $terms = sortStdArray($terms,"name");

  7. jordan@madebythisguy.com
    Member
    Posted 1 year ago #

    Awesome! I was having the same syntax issue. Thanks Micheal!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic