Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

reply

  • Hi @Hube2

    Thanks for the feedback. Totally agree and I will have a look at why this isn’t already added

  • Hi @Debatewise

    Can I ask you to clarify what post types have what custom fields?

    Does the Promo Box post type have a ‘taxonomy’ custom field? If so, what is the name of this field and what is the return type?

    Next, where does the code come from that you have shown? Is that the code that is run for a Promo Box?

    Most likely, all you need to do is use the get_field on the taxonomy custom field to find the term ID selected

  • Hi @JCIDEV

    The $post_id parameter needs to be the $taxonomyName + $termID.

    Your taxonomyName is actually ‘category’, not ‘alabama’ (alabama is your term name)

    Modify your code to:

    
    the_field('test_field', 'category_' . $term_id);
    

    and that should work

  • Thanks for your quick reply. There’s probably something I’m not understanding about $term_id. I have a regular WP post category of “stories-by-state” which has subcategories of each state (alabama, alaska, etc.). I don’t think the fact that I’m retrieving subcategory info has any effect on the outcome.

    Given your instruction, I would have something like the folowing:

    the_field('test_field', 'alabama_' . $term_id);

    or

    the_field('test_field', 'alabama_16');

    where 16 is the the number I get from the ur:l /wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=16&post_type=post

    Neither worked and I”m not 100% sure how to pull $term_id.

  • You’ll need to set the second function parameter to ‘category-slug_2’ where ‘2’ is the term ID. So for example:

    
    the_field('test_field', 'beer_' . $term_id);
    

    would output the “test_field” value for the term with ID $term_id in the “beer” taxonomy.

  • Just to clarify, you are asking how do you load a custom field value from a taxonomy term when you know the taxonomy type and the term ID?

    Please read this documentation article:
    http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/

  • @moncero,

    Try replacing ‘category_’ with your custom taxonomy slug

  • Well, I’ve tried the same with a new WP install and works perfectly!
    I had once installed a categories related plugin which was removed. I guess that broke something permanently in my site.

  • Hi there @Hube2,

    I too have required this functionality today, due to being at work I am unable to test this for a variety of taxonomies although I have used it for shopp-categories.

    Please let me know how you get on with this.

    https://github.com/WazzaJB/ACF-Taxonomy-Depth-Rule

    Wazza

  • Hi @Hube2

    Currently, this is not possible. However, it is very possible to create your own custom location rule!

    You could create a rule to look at the taxonomy term’s parent and then return true / false depending on the result.

    You can read how to create a custom location rule here:
    http://www.advancedcustomfields.com/resources/tutorials/custom-location-rules/

  • Hi @landitus

    Yes, please do re-check this on another install.

    Failing that, are you able to do some simple debugging in the taxonomy file?

    Take a look in ‘core/fields/taxonomy.php’ in the update_value function.

    Use a simple debugging method to check that the wp_set_object_terms function is running

  • Hi Elliot, thanks for The reply.
    – ACF does indeed read all changes made with the native categories metabox. It looks like ACF can’t change and save data.
    – I have 2 more ACF fields and they save just fine.

    I am using the latest WordPress and ACF. Maybe I Should try a brand new wordpress install just to re-check.

  • Hi @rddesigns

    ACF saves the value of ‘term’ custom fields to the wp_options table.
    The option_name will have a prefix of $taxonomy_$termID_$fieldName

    I hope that helps

  • Hi @landitus

    If you use the native WP checkbox to change the category, does ACF read in the new terms selected?

    Perhaps the issue is ACF is not saving the data?

    Can you confirm that ACF is saving other custom fields?

  • Hi @harini

    Thanks for the detailed description of the issue.

    I believe the the solution is quite simple, and is the fact that you care using the wrong $post_id parameter to load data from a taxonomy term.

    Please read over this article and pay special attention to the post_id param:

    http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/

    Your post_id param should be

    'category_' . $category_id

  • Hi,

    How familiar are you with looping through an array and matching a value?

    Your above code looks to have successfully found the $current_parent_id.

    Perhaps you should look over the code for the repeater field, learn how to loop through the rows of data, and use a simple if statement to match the row to the current taxonomy ID.

  • Thanks for the full code.

    This is great to look at, however, can I ask you to very clearly describe the issue. You say the issue is getting the date tags data.

    Is the issue using the get_sub_field like in the following code?

    
    $date_tags = get_sub_field('pro_perf_time_tag'); 
    

    Or is the issue looping through the $date_tags array and loading the data.

    Can you please go through your ode line by line and debug the variables.

    Thanks
    Elliot

  • Elliot –
    Here is the full section of code.

    <?php if(get_field('pro_perf')) { 
    	   while(has_sub_field('pro_perf')) {
    	        $date_id = 1;
    	        echo '<p> ' . get_sub_field('pro_perf_date') . '<br /> ';
    		if(get_sub_field('pro_perf_time_repeat')) {
    	        	while(has_sub_field('pro_perf_time_repeat')) {
    			    if($date_id <= 1 ) {
                                   $date_tags = get_sub_field('pro_perf_time_tag');
    			       if($date_tags) {
                                    foreach($date_tags as $date_tag) {
    	$t_data = get_option("event_tag_$date_tag->term_id_term_color");
    	echo $t_data;
    echo '<span class="tagbox" style="background:' . $color . ';">' . $date_tag->slug . '</span>';
    				}
    																			
    echo '<a class="date" href="' . get_sub_field('pro_perf_time_link') . '">' . get_sub_field('pro_perf_time') . '</a>';
    
    				} else {
    
     echo '<a class="date" href="' . get_sub_field('pro_perf_time_link') . '">' . get_sub_field('pro_perf_time') . '</a>';
    				}
    
    			} else {
    
    									$date_tags = get_sub_field('pro_perf_time_tag');
                                   if($date_tags) {
                                           foreach($datetags as $datetag) {
    									      echo '<span class="tagbox"> ' . $date_tag->slug . ' </span>';
                                           }
    									
    echo ' | <a class="date" href="' . get_sub_field('pro_perf_time_link') . '">' . get_sub_field('pro_perf_time') . '</a>';
    				} else {
    echo ' | <a class="date" href="' . get_sub_field('pro_perf_time_link') . '">' . get_sub_field('pro_perf_time') . '</a>';
    			        }
         			}
    			$date_id ++;
    		}
    	}
    
    	echo '</p>';
    }
    }?>
    

    Also, to answer your other questions, in my rushed state to post, I did not see the code button as an option. I am also fairly new to forums like this and the truth is it was just laziness and frustration but in the future I will make sure to properly address those issues and be a better community member.

  • Also, as this is the new support forum (currently in beta) I have a few questions for you if you don’t mind:

    1. Why did you not place your code within code tags as seen in the wysiwyg editor?
    2. Why did you not place the topic in the ‘General’ category when it would be better placed in ‘Repeater field’ or ‘Front end’?
    3. Why did you not enter any tags for the topic for users to search for in the future?

    Thanks

  • Can I ask if you have read through the documentation for the repeater field, and have correctly used a has_sub_field loop?

    Perhaps you could show all the loop code, that would help find the issue

Viewing 20 results - 4,526 through 4,545 (of 4,545 total)