Tell us what you are trying to do?
I'm using Fields and Text to display a hierarchical taxonomy. The ordering is alphabetical which means that the parent tag isn't at the front of the list.
In the image attached, "HR" is the parent, and needs to be ahead of the others.
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site?
Hi,
Thank you for contacting us and I'd be happy to assist.
To show the post's taxonomy terms ordered by the 'parent', you'll need a custom shortcode:
add_shortcode( 'get_terms_custom_order', 'get_terms_custom_order_func');
function get_terms_custom_order_func($atts) {
$a = shortcode_atts( array(
'id' => '',
'type' => '',
'orderby' => '',
'order' => '',
'sep' => ''
), $atts );
$terms = wp_get_post_terms( $a['id'], $a['type'], array('orderby' => $a['orderby'], 'order' => $a['order']) );
$sep = $a['sep'];
$output = '';
foreach ( $terms as $term ) {
$term_link = get_term_link( $term );
$output .= '<a href="'.$term_link.'">'.$term->name.'</a>';
$output .= $sep;
}
return rtrim($output, $a['sep']);
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
After that, you can use this new shortcode in your template's "Fields and Text" block like this:
[get_terms_custom_order id="[wpv-post-id]" type="taxonomy-slug" orderby="parent" order="ASC" sep="<br>"]
Note: Please replace "taxonomy-slug" with the slug of your target taxonomy.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Hi Waqar!
Than you for the code. I think it's fair to say that I've done something wrong as I seem to have a shortcode on the front end. I've attached some screen grabs… Yikes!
Thanks for writing back.
Can you please add new shortcode's name "get_terms_custom_order" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content and then check the page again?
In case the issue still persists, you're welcome to share temporary admin login details, along with the link to the page where you've added this shortcode.
Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.
Thank you for sharing the admin access.
The JetPack plugin's "Secure Sign On" feature is not allowing me to access the website's admin area.
( ref: hidden link )
Can you please disable this feature from the JetPack's settings, during the course of this investigation?
Good afternoon Waqar,
I have just disabled the settings in Jetpack as requested.
Thank you
Lesley
Thank you for enabling the admin access.
For some reason, the code snippet for this custom shortcode was keep getting deactivated in the custom code section.
I've updated the second last line of the code from:
return rtrim($output, $a['sep']);
To:
And it seems to be working now.
( screenshot: hidden link )
My issue is resolved now. Thank you!