Support

Account

Home Forums ACF PRO Display Taxonomy field

Solving

Display Taxonomy field

  • Hi there,

    I have a Taxonomy selector field named SelectTaxonomy(slug selecttaxonomy)and I have a few question about display:

    Firstly, <?php echo the_field('selecttaxonomy'); ?> returns the numeric ID (115) not the name (Bike Rides) or the slug (bikerides).
    How do I get the name please.

    Second,
    Part of my code is the array:

    $product_args = array(
    'post_type' => 'download',
    'posts_per_page' => $per_page,
    'offset' => $offset,
    'download_category' => 'bikerides');
    $products = new WP_Query($product_args)

    ;
    ETC
    How do I change the ‘bikerides’ to be the value (name or slug) of the taxonomy field please (I assume that I’d have to create a variable)?

    Lastly, How do I get the field displayed as a inputable dropdown on the front end please.

    Many thanks

    Paul

  • 1) Display of taxonomy fields is covered here https://www.advancedcustomfields.com/resources/taxonomy/. You can’t use the_field() with this type of field.

    2) You need can use tax_query if you are saving and loading terms. Otherwise you need to use meta_query. For the meta_query you need to search for the Term ID in a like query. See this page https://www.advancedcustomfields.com/resources/query-posts-custom-fields/ 3. Multiple custom field values (array based values). In this case the values to look for will be LIKE "'.$term_id.'"', note the quote marks (“) around the term ID.

    3) Not sure what you are looking for on this
    ...How do I get the field displayed as a inputable dropdown on the front end...

  • Hi John,
    1) This dosn’t work (it displays nothing):

     <?php 
    $term = get_field('selecttaxonomy');
    if( $term ): ?>
    	<h2><?php echo $term->name; ?></h2>
    	<p><?php echo $term->description; ?></p>
    <?php endif; ?>

    Am I missing something?

    2) I’ve already looked at this and didn’t understand it then either! Is there a tutorial video?
    ('meta_value' => 'Melbourne' Melbourne is still typed in and not the selected value of the field)

    3) Sorry, my bad english.
    What I want is for the taxonomy field to be a (selectable) drop down list on the front end instead of just the backend.

    Many thanks
    Paul

  • For your last question I would look at this https://www.advancedcustomfields.com/resources/creating-wp-archive-custom-field-filter/.

    I don’t know what the first code is not working for you. Where are you trying to get the value of the field? Is it in “The Loop”

  • Hi there,
    On the first question; I can get the numeric id of the download_category but, for the life of me, I can’t get the text (either the title or slug).

    Thanks for the link but it’s beaten me -what do I change?
    Do I need the javascript (I don’t want to change the url)?
    How do I show the related fields (thumbnail, title & button)?
    All I’m getting is a blank screen.

    My page is: https://ageingdj.com/0anotheredd-test/ all I want is a dropdown box or a checklist instead of the “115”
    Sorry to be such a pain.
    Paul

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

The topic ‘Display Taxonomy field’ is closed to new replies.