1) I’ve created a custom taxonomy called ‘locations’, populated with names ‘location1’, ‘location2’, etc.
2) I’ve created a taxonomy ACF field called ‘location’, with multiple select input, based on the custom taxonomy ‘locations’.
3) I’m using this code to retrieve the selected locations and display them in a widget associated with the post:
$location = get_field('location');
foreach( $location as $term ): ?>
<a href="<?php echo get_term_link( $term ); ?>"><?php echo $term->name; ?></a><?php if ($term !== end($genre)) echo ', ';
All of this works perfectly well.
My problem is that when I click on a location name URL (which is correctly displayed like: “http://www.mywebsite/locations/location1”), it leads to a ‘not found’ page.
(Doing the exact same thing with the same php code for other custom taxonomies, not using ACF, works fine.)
When I check the ‘locations’ custom taxonomy table, nothing seems to be saved, hence the problem…
What went wrong? 🙂
Do you have posts assigned to the terms in the locations.
I just tested this than then the terms don’t have posts then I get a not found message, indicating that there are no post to be found, not that the page is not fount when I add a post in the term then the page shows my post.
Try adding some posts to each of your terms.
It’s very weird, yes I had posts including the terms, since the link above is generated from posts themselves.
But for whatever reason it seems to be working now. I don’t know what happened.
Thanks anyway! 🙂