Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

reply

  • cs_industry is a taxonomy attached to the custom post type ‘case_study’. It does seem to save the values I tick for each post. Not sure if that answers your question?

  • If I understand you correctly (let’s just look at one taxonomy)

    You have a taxonomy, when editing a term in the taxonomy you select posts that should be in that taxonomy?

    If this is correct then you’re doing this backwards. In WP the relationship works the other way. You would put a “Taxonomy” field on the “poat” and when editing the post you would select the Term that the post belongs to. This causes WP to create the correct relationship so that it will do what you’re looking for.

  • Conditional logic currently only works on choice fields. I’ve heard some rumors about it possibly adding to things like taxonomy fields but I can’t confirm that. It does not work on the presence or absence of a value in a field. For this you’d need to create you own JavaScript to handle the hiding/showing of a field. There isn’t much in the way of information on how to accomplish something like this. The only information on adding custom JS is here https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/. I have posted some examples of doing some things with JS here that may get you started on how to detect changes in fields and modify other fields here https://github.com/Hube2/acf-dynamic-ajax-select-example

  • First of all, thank you for your continued help. I really appreciate it.

    I tried the code you suggested, but haven’t yet solved either of the issues. I feel like we’re getting closer to finding the issue.

    The cs_industry is a taxonomy relating to the custom post type “case study”. And the variable $relatedCat does give a number (e.g. 1079).

    When I print_r($args), I get:
    Array ( [posts_per_page] => 3 [post_type] => case_study [meta_query] => Array ( [0] => Array ( [key] => cs_industry [value] => "1079" [compare] => LIKE ) ) [orderby] => DESC )

  • There is one thing I just noticed as far as the meta_query goes.

    First of all, if you’re field is not returning an ID of the “ct_industry” assuming that this is some type of relationship field, then you need to get the unformatted value.

    Secondly, since you are searching for numbers in a field that contains arrays then your LIKE needs to be altered.

    All of the following are guesses assuming that “ct_industry” is either a taxonomy or a relationship field.

    
    $relatedCat = get_field('service_related_industry', false, false);
         $args = array (
    		'posts_per_page' => 3,
                    'post_type' => 'case_study',
    		'meta_query' => array(
    			array(
            		'key' => 'cs_industry',
    				'value' => '"'.$relatedCat.'"',
    				'compare' => 'LIKE',
    				)
    			),
    		'orderby' => 'DESC',
          );
    	 if (!$relatedCat) { 
    		 $relatedCat = get_field('service_related_category');
    		 unset ($args);
         	 $args = array (
            	'posts_per_page' => 3,
            	'cat' => $relatedCat,
            	'orderby' => 'DESC',
          	 );
    	 }
    

    as far as why it’s returning the wrong number of posts, yes, a pre_get_post filter added somewhere else can alter the settings of any query done anywhere and any time https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

  • I was able to solve the problem of birthdays by calculating age through this tip.:
    doitwithwp

    And put to work in the taxonomy with adataption of the display:
    $rows = get_field('ocupacao', $taxonomy . '_' . $term_id);

    After I just needed to create a wysiwyg field it could be just text and put the shortcode and the magic happens =)! I hope to help others who have doubts =).
    [show-my-age birthday="02/13/1985"].

  • yes I did, here is the code I am using.

    function change_post_taxonomy_44582( $post_id ) {
       
        if ( empty($_POST['acf']) ) {
            return;
        }
        
         // get term id from $post_id (only 1 value is allowed, so it returns 1 value only)
        $stored_role = wp_get_post_terms($post_id, 'asproducts_cats');
        // get submitted value from acf form
        $posted_roles = $_POST['acf']['field_59154e83efb0e'];
        // get term_id for the submitted value
       
        $term_id    = get_term_by( 'name', $posted_roles, 'asproducts_cats' );
        // if stored value is not equal to posted value, then update terms
       
        if ( $stored_role[0] != $posted_roles ) {
            wp_set_object_terms( $post_id, $term_id->term_id, 'asproducts_cats' );
        }
    }
    add_action('acf/save_post', 'change_post_taxonomy_44582', 20);

    Also have a look here https://support.advancedcustomfields.com/forums/topic/conditional-logic-using-taxonomy-field/page/4/

    A nice chap helped me out with this. Shout if you are still having issues

    Keith

  • I used this code and now it seems to work.
    <?php the_field('date_nasc', $taxonomy . '_' . $term_id); ?>

    Hello I managed to resolve a few hours ago =). The only thing I can not solve now is to show the age. For example here in the forum I found some things. It just does not work. I also tried to use the terms nothing. I wanted to include for example: Personality was born in 1981. I can not calculate it 12/16/1981. And show the age of personality. Is there any code here in the forum that is possible to make it work within the taxonomy?

  • What code are you using in taxonomy-slug.php to show the value of the field?

  • It’s not really a bug, the taxonomy field in one row of a repeater does not know what’s going on with the same field in another row. It would be possible to “append” values, but then there is the issue with “removing” values first. For example, in you changed the selected term in a row and ACF used the append terms version of the function then the term you wanted to remove would still be there. ACF solves this by replacing all the terms whenever it updates a taxonomy field.

    At any rate, I would to something along the lines of this after change the field to not load or set terms. But you should be aware that you will not be able to set these taxonomy/terms anywhere but in the ACF field.

    
    add_action('acf/save_post', 'update_repeater_post_terms');
    function update_repeater_post_terms($post_id) {
      if (get_post_type($post_id) != 'YOUR POST TYPE HERE') {
        return;
      }
      $terms = NULL; // this will clear terms if none found
      if (have_rows('YOUR REPEATER', $post_id)) {
        $terms = array();
        while (have_rows('YOUR REPEATER', $post_id)) {
          // add this term to the array
          $terms[] = get_sub_field('YOUR SUB FIELD', false); // false for no formatting
        }
      }
      set_object_terms($post_id, $terms, 'YOUR TAXONOMY HERE', false);
    }
    
  • Thanks so much for the reply, John. But…this seems like a pretty big bug, no? You just can’t reliably save any values in a repeater to a taxonomy?

    I confess I don’t really have any idea how to write the sort of code you recommend. Is there any place you could point me to that might clear things up? Thanks again.

  • This is probably because you have selected “Load Term” and “Save Terms”. This causes ACF to update the terms separately for each field and the only one that sticks is the last one. Basically, you can’t load and save terms when dealing with a repeater.

    I’ve seen this discussed before, but I don’t know if it was ever solved by anyone.

    I would probably turn off these settings for the taxonomy field and I would create my own acf/update_value for the repeater field that would set the post terms so that multiple terms can be added all at once https://codex.wordpress.org/Function_Reference/wp_set_post_terms

  • 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

  • 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...

  • I have open a new thread https://support.advancedcustomfields.com/forums/topic/post-select-value/ because your code was good and helpful to get the taxonomy by key_field but I have another issue to make it set the category on my cpt.

  • I deleted the old taxonomy and re-created a new one and it looks like it’s working. I’ll go testing it slowly =).

  • Hello, sorry I typed wrong. The site is showing up and the urls are running. I’m just watching, when I’m registering the fields within the post. When saved the post is repeating the same taxonomy. I’ll test if it’s any backend conflict. The good that urls now seem to work. =). Thank you very much. You were very collaborative. This is a personal project in the imdb style. Soon I’m creating many custom files. It’s a project that I’ve already been developing for almost five months.

  • Hello, I saw your message in the other forum. I had already done as you reported. But it does not work all over the site I only have problems in that part. I’m thinking of creating another term instead of short codes to call properly. Because every time I use the field to call taxonomy the site disappears in half.

  • I want to help you but your English is not optimal so it’s hard to understand at some points.

    If you have a field for taxonomy, it returns should return either an object or a taxonomy id. So if you echo $row[‘term_link’] it will not be a link, but an object or an ID.

    So instead of $row[‘term_link’] it should be get_permalink($row[‘term’]) (to create a link out of the returned value).

    “I left without filling the taxonomy, of course nothing will appear, but the content with the images of the gallery appears normally.”

    If you leave out the taxonomy selector, the rest should still show since they’re not depending on each other (as far as I can see in your code).

    I think it would be a lot easier if I could look at (all) your code. If you’re online, contact me through my website, maybe I can help you out. Might go faster than this.

  • I tried putting it in row to draw a conclusion. Simply the content filled it out, and all the content below in the first image. However, in the second image, I left without filling the taxonomy, of course nothing will appear, but the content with the images of the gallery appears normally. Is it some taxonomy bug? I’m just finding problem with this code, above. You sent me the term_id | object should I create a while for this?

     <?php $rows = get_field('actor');
                     if($rows){
                    echo '<ol class="people scroller">';
                        foreach($rows as $row){
                           echo '<li class="card"><a href='. $row['term_link'] .'><img width="138px" height="175px"  class=" profile fade lazyautosizes lazyloaded" src=' . $row['image-profile'] . ' alt=' . $row['primeiro_nome'] . '> </a><p><a href='. $row['term_link'] .'>'. $row['primeiro_nome'] . ' ' . $row['ultimo_nome'] . '</a></p><p class="character"> ' . $row['personagem_atual'] . '</p></li>';
                          }
                        echo '</ol>';
    
                        }
    
          ?>

  • My problem is when I choose the name of the actors in the front end, only the link of the first actor appears for all. If I put $ term-link to taxonomy it appears: mysite / personal / name-actor. Now if I put row [] it only appears mysite / name-post. However, when I choose the first option. All fields in the image above the url is only for charlie-cox.

    Even selecting all the actors with the correct term. Just the mysite / personal / charlie-cox url. It appears in all fields on the front end rather than appears only in the field that I selected. I hope I have been able to explain correctly now. =)…

  • My problem is when I choose the name of the actors in the front end, only the link of the first actor appears for all. If I put $ term-link to taxonomy it appears: mysite / personal / name-actor. Now if I put row [] it only appears mysite / name-post. However, when I choose the first option. All fields in the image above the url is only for charlie-cox.

    Even selecting all the actors with the correct term. Just the mysite / personal / charlie-cox url. It appears in all fields on the front end rather than appears only in the field that I selected. I hope I have been able to explain correctly now. =).

  • If I put only the $ term_link, it recognizes the taxonomy and shows the path of the taxonomy, but if I put it in row it shows the url of the post and not the taxonomy.

  • This is my repeater field. When I choose multiple selections or just single selection. Every time saved the name actor charlie cox doubles in the backend. When I place the taxonomy inside row.

    http://res.cloudinary.com/meugamer/image/upload/v1519491030/taxonomy-actor_qeluxe.jpg

  • The term_link I placed to automatically pull the taxonomy. As the name of the taxonomy is an actor, I realized that it could pull without I having the need to create a field and include it there. Because every time I create a field the names of the first field is duplicated with the others.

Viewing 25 results - 1,601 through 1,625 (of 3,193 total)