• Resolved giuvit

    (@giuvit)


    Hi,
    I need the feature to show, on frontend, taxonomies in the order as I selected in the backend.

    <?php $terms_cert = get_the_terms($post->ID, 'certificazione');
    		
    		//echo '<span class="tagged_as"><label>Certificazioni:</label>';
    		foreach ($terms_cert as $cert)
    		{
    			$cert_link = get_term_link($cert, 'certificazione');
    			if (is_wp_error($cert_link)) continue;
    			$cert_products .= '<a target="_blank" href="' . $cert_link . '"> ' . $cert->name . '</a>, ';
    		}
    		$cert_show = substr(trim($cert_products) , 0, -1);
    		echo ! empty( $cert_show ) ? '<span class="tagged_as"><label>Certificazioni:</label>' . $cert_show : '';
    		echo '</span>';
    		?>

    This is the code to show the taxonomy on frontend on meta.php, but in whatever order I select them on frontend, it always shows them ordered by name.
    How I can order the in the other mode? Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hmm, at least with the core function above, get_the_terms() I’m not seeing any parameters/built in ways to specify the ordering. Even tracing my way into the other core functions used here in its stack trace, none of the ordering parameters mention “order in the way listed in the admin” or similar wording.

    Not sure how much extra work you maybe wanna do but I could see a custom field with linked-to terms being one way to achieve this, but it could easily get out of sync if term items get updated somewhat regularly.

    Thread Starter giuvit

    (@giuvit)

    Mmmm, so you suggest to maintain the taxonomy and use it in a customfield so the user can order it as it wants? How I can do it?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    My idea was a suggestion, not necessarily a “this is a best practice”. Basically list, perhaps include links/html for clickability, all saved as a single field, in the order desired. Then on the frontend where you’d normally list the terms, instead fetch this meta field and echo that. I suspect it’d be a lot of extra work though, especially if you’re avid taggers for categories/tags/terms.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fronted order for taxonomies’ is closed to new replies.