Tag Info

New answers tagged

0

Assuming the position field is filled with numbers to give order: have a look at ksort. <?php $terms = get_terms('brands'); // Let's create our own array and then reorder it $order_terms = array(); foreach( $terms as $term ) { $position = set_up_the_position_meta_here; ...


2

I think it will be easier to make use of the category slug, and not the name. It is already in lowercase and hyphen separated if you have more that one word. The problem with using the name and adding hyphens is that you will not get a match and most probably just 404. %20 is how blank spaces is encoded in a URL. You can just replace $category->cat_name ...


2

Try this <a href="/category/<?php foreach((get_the_category()) as $category) { echo $category->slug . ' '; } ?>"> Hope this helps.


0

Change this: echo $category->cat_name To this: echo $category->cat_slug A better way would probably be to use: $cat = get_the_category(); $cat_link = get_term_link( $cat ); That will have $cat_link as the full permalink. echo '<a href="' . $cat_link . '">' . $cat->cat_name . '</a>'; Using your code above: <a href="<?php ...


1

If using get_the_terms, you can just do your if loop once for each taxonomy and then join them after the three loops. Of course, it would probably be more efficient to use: wp_get_post_terms( $post_id, $taxonomy, $args ); You could then do something like: wp_get_post_terms( $post_id, array( 'resource_roles', 'resource_media', 'resource_theme' ) ); ...


0

It is too specific of a condition for there to be a native way. On other hand this is hardly complicated as simply sorting an array in PHP. You can use usort() with a small custom callback, containing your comparison logic.


1

$albumGenres = get_the_terms( $post->ID, 'discography_album_label' ); foreach ( $albumGenres as $albumGenre ) { echo $albumGenre->name; // or whatever value }



Top 50 recent answers are included