Support

Account

Forum Replies Created

  • The reason why I can’t do as you suggest is because enabling that option severs the link between the ACF taxonomy field and the data it’s trying to store.

    From what I’ve seen in ACF5, when this option is enabled and I select “Toronto” from the “Born” dropdown, two things happen. First, “Toronto” is assigned to the post as a tag (or in my case as a custom taxonomy term) and second, the “Born” dropdown reverts to default (meaning “Toronto” no longer appears in the “born” dropdown).

    So no, this isn’t a realistic solution, which is why I’m doing what I’m doing.

  • Would be really great if there was a way to simply modify the $indent value in the walker, avoiding all this hackery, but I’m glad it was indeed possible.

  • Figured this out thanks to this thread and other help online. Add a new filter:

    add_filter('acf/fields/taxonomy/wp_list_categories', 'md_format_citytax_terms_in_selectbox', 10, 2);

    then use that to replace the walker

    function md_format_citytax_terms_in_selectbox( $args, $field ) {
    
    	$args['walker'] = new md_taxonomy_field_walker( $field );
        return $args;
    }

    then dupe the walker code from core/fields/taxonomy and replace mdash; with three nbsp; and presto, problem solved.

  • Progress.

    With this code in functions.php I can get the AND posts; that is, posts tagged with “Toronto” AND posts that have “Toronto” assigned to the meta_city field.

    I need the “OR” of course. Still searching. All feedback is welcome.

    
    add_action( 'pre_get_posts', 'md_modify_tag_archive_to_include_acf_fields' );
    
    function md_modify_tag_archive_to_include_acf_fields( $query ) {
    	if( $query->is_main_query() && $query->is_tag ) {
    		$term_name = $query->query[tag];
    		$term = get_term_by('name',$term_name, 'post_tag');
    
    		$meta_query = array(
    			'relation' => 'OR',
    			array(
    				'key' => 'meta_city', // name of custom field
    				'value' => $term->term_id, 
    				'compare' => 'LIKE'
    			)
    		);
    		$query->set( 'meta_query', $meta_query);
    	}
    
    }
    
Viewing 4 posts - 1 through 4 (of 4 total)