Support

Account

Home Forums Backend Issues (wp-admin) 'Tweak' taxonomy select

Solving

'Tweak' taxonomy select

  • I tried to tweak a taxonomy select by adding the filter “add_filter( ‘acf/fields/taxonomy/result’,….” and it works…… but what i want to get is:

    – parent terms are in “BOLD” – it works
    – child terms are without “- ” – it works

    – only child terms are selectable ????? no idea how to do this
    – parent terms are not selectable ????? no idea how to do this

    trying to have another layout for selection and selected ->
    in search field there should be “- termname” but in selection there should be “termname”

  • I’m also looking for solution, if anyone can suggest any pointers that would be great.

  • ACF calls the function wp_list_categories() to show a select field for taxonomy fields.

    To alter the display of the select field you must build a custom walker.

    You can alter the walker used by the field using the filter on acf/fields/taxonomy/wp_list_categories

    
    $args['walker'] = new YourCustomWalkerClass();
    

    Beyond this I can’t really help you much.
    Here is one tutorial https://phppot.com/wordpress/wordpress-custom-walker/
    many more can be found by searching the web for “wp_list_categories custom walker”

  • This reply has been marked as private.
  • Not sure why you made your comment private.

    Like I said, I don’t know anything about building custom walkers and I don’t know why it would not be working.

    As far as my knowledge goes, when using a select field for taxonomy terms is that ACF calls wp_list_categories() and one of the filterable arguments for this function is ‘walker’.

    The best I can do is tell you how to see if your filter is being called. For this turn on WP Error Logging and then call the PHP function error_log() inside of your filter and see if your messages is logged. This is the only way to tell because it is a AJAX request. Your filter will only run when you click into the field and ACF tries to load more choices.

    If you want to possibly get input from someone other than me then you need to make your comment public, but it reality, your best choice for information on building a custom walker for WP is probably not this forum.

  • I’m now facing exactly this same issue https://support.advancedcustomfields.com/forums/topic/add_filteracffieldstaxonomyquery-bug/#post-30884 filter is not getting called.

    I’m using WP 6.4.

  • I have steered you wrong.

    acf/fields/taxonomy/query is used for select fields and the select field does not use wp_list_categories()

    Select fields are rendered using ACF’s select field rendering, the only way to alter the title is with acf/fields/taxonomy/result, if that does not work then it is not possible.

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

You must be logged in to reply to this topic.