ah.. I see..
I’ll use yours then.. =]
Thanks for the advise! ^_^
Thank you for the suggestion anyway. I’m pretty new in PHP so my code might really seem unsemantic or such. Will work on that ;]
Thanks! =]
Hi!
Well, it shouldn’t be listed as a “list” as in
or
.. I want it listed in one line without touching the css so I coded it that way.. Also, there is a possibility that not all the Doctors will have a “Sub Specialty” that’s why there’s this line of code:
<?php
if (get_field('sub_specialty') != '') { ?>
I removed the array($terms);
too. =]
Here’s my final code on displaying the term name:
<?php
$terms = get_field('sub_specialty');
foreach ($terms as $term){
$subspec[] = '<a href="'.$term->slug.'" name="'.$term->slug.'" alt="'.$term->anem.'">'. $term->name .'</a>';
}
echo implode(' / ', $subspec);
?>
Hi Jonathan!
I switched the return value to Term Object as your reco but the code did not work. Anyways, I fixed it already and here’s my working code:
<?php
/* sub specialty */
if (get_field('sub_specialty') != '') { ?>
<strong>Sub specialty.:</strong>
<?php
$terms = get_field('sub_specialty');
array($terms);
foreach ($terms as $term){
$subspec[] = '<a href="'.$term->slug.'" name="'.$term->slug.'" alt="'.$term->anem.'">'. $term->name .'</a>';
}
echo implode(' / ', $subspec);
; ?>
<br />
<?php } else { ?>
<?php } ?>
I added some codes too according to how I want it to be displayed.
Thanks for replying btw. =]
God bless!! ;]
Hi! The custom post type is “dims”.. the Departments is a custom taxonomy… =]
Here is how I want it to be:
I have a custom post type “Doctors”, each “Doctor” are assigned in different “Department” and has “Sub-Specialty/Specialties”..
The Sub-Specialty should have the same list as of the Department, so I used the Relationship > Taxonomy of ACF to call the list of “Departments”. It’s working on the back-end, but on the front-end, what being displayed is the Item ID of the “Department” not the Item Name/Value.
The taxonomy “Departments” is in checbox format.. =]
Thanks!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.