Home Forums Front-end Issues Display of custom taxonomy page


Display of custom taxonomy page

  • Hello,

    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');
    if( $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&#8221;), 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? 🙂
    Thanks !

  • 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! 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Display of custom taxonomy page’ is closed to new replies.