Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

reply

  • I just tested this on ACF 4.4.2 and WP 4.2.2, an it seems to be working for me.

    Just curios if you also recently updated to WP 4.2 or later and if it stopped working at that point.

    Do you have terms that are associated with this post type that are also in other taxonomies?

    The reason that I ask is that in WP 4.2 shared taxonomy terms started getting split https://make.wordpress.org/core/2015/02/16/taxonomy-term-splitting-in-4-2-a-developer-guide/

  • Couple of questions, when you say “collection” of posts, how are you creating this collection? As part of a taxonomy of is just in the relationship field? Do you have multiple post types that you’re using? So basically more information on what you have so far.

    I have a couple ideas on how you could go about this and could outline them, but that really depends what you have set up so far.

  • Instead of “Post Category” choose “Post Taxonomy”

  • The first thing that you need to do is to get the terms that the post is in.

    
    $post_id = $post->ID;
    $taxonomy = 'custom-category';
    $args = array('fields' => 'ids');
    $terms = get_post_terms($post_id, $taxonomy, $args);
    

    $terms will hold an array term ids that the post is in. For more information on this see https://codex.wordpress.org/Function_Reference/wp_get_post_terms

    Once you have a list of terms you can get the images from those terms. In the below I am using “image_field” for the name of your image field.

    
    for (i=0; i<count($terms), i++) {
        $term_post_id = $taxonomy.'_'.$terms[i];
        $image_url = get_field('image_field', $term_post_id);
        if ($image_url) {
            // your code for showing the image here
        }
    }
    

    For more about getting values in acf from things like taxonomy terms see the Get a value from other places section on this page: http://www.advancedcustomfields.com/resources/get_field/

  • I’ve testing the wysiwyg field on category taxonomy and it’s working in both ACF4 & 5.

    My guess is that there is some kind of interference from another plugin.

    Do you have any other plugins on the site that effect the WYSIWYG editors on the site?

  • I just did some testing on this. Make sure that you’ve populated your tag taxonomy withe some tag names. After doing that the ability to select tags becomes available.

  • Hi! Oembed works for fields on category page? For me it doesn’t.
    I can show the field (I am using the code presented here ) but the link looks like a regular one (https://hereyoutubelink), doesn’t get transformed into iframe. Theme is twenty twelve.

  • I’ve just looked into the source code and didn’t find the Group Titles.
    But i know how to add the titles.

    In /forms/taxonomy.php

    I added this:

    if( $field_group['style'] == 'default' ):
    echo '<h3>'.$field_group['title'].'</h3>';
    endif;

    taxnonomy.php

  • I am having a similar problem with the latest free version.

    the problem only happens in Chrome and IE. Firefox is fine

    I have 3 CF’s on a page with logic controlling each (selecting the last item in the select box on CF1, brings up CF2, selecting an item on CF2 will bring up one of a number of CF’s for CF3)

    When I select anything in the drop downs, all CF’s apart from the first one disappear. again in Firefox it’s fine though, i see an ajax spinner and the fields appear

    i thought it might be because I have multiple “If Post Taxonomy = [something]” logic entries where each taxonomy condition points to a different Custom Taxonomy but i reduced it to one taxonomy and the problem still existed.

    I looked at the ajax response body.. in Firefox i get several back eg [121,156,150,163]

    in Chrome i get some blank entries then 121 (121 is the first CF)

    I do get this warning in chrome from jQuery when i first load the page. I don’t know if it is related “Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience.”
    discussed here http://stackoverflow.com/questions/27736186/jquery-has-deprecated-synchronous-xmlhttprequest

    any advice greatly appreciated

    thanks
    j

  • Hi,

    I don’t know if we are sharing the same issue (and for me, the issue stretches further back than 5.2.5) but I’ve figured out mine.

    The Context:

    The project I’m currently working on uses Polylang for translations. Custom fields aren’t set to be translated, their data is synced manually.

    I have a post object setup to retrieve posts from two custom post types: partner and sponsor. These post types aren’t configured to be multilingual.

    The Issue:

    In acf_field_post_object::render_field(), if there’s a saved value, ACF will retrieve all posts matching the saved value (in order to pre-populate the rendered field).

    
    $posts = acf_get_posts(array(
    	'post__in' => $field['value']
    ));
    

    Unfortunately, this returns an empty array because acf_get_posts() will default to loading from all available post types. In my case, acf_get_post_types() returns: post, page, attachment, partner, and sponsor.

    And this is the key problem: post and page are configured to be multilingual. This triggers Polylang to add a condition to fetch posts in the current language which the non-multilingual post types can’t fulfill.

    First Solution:

    Require ACF to pass along the filtered list of post types:

    
    $posts = acf_get_posts(array(
    	'post__in' => $field['value'],
    	'post_type' => $field['post_type']
    ));
    

    The one downside of this is if the list of filtered post types changes (e.g., a post type is removed), it will affect any currently saved value assigned to that now-removed post type.

    Second Solution:

    Intercept Polylang before it adds that language condition to the WP_query. I accomplish this using a backtrace to figure out if the WP_query was called by acf_get_posts() by way of acf_field->render_field().

    **Updated 2015-05-21T17:22-05:00**

    
    add_action( 'pre_get_posts', function ( &$wp_query ) {
    	$is_acf_get_posts = (
    		   ( $e = new Exception )
    		&& ( $trace = $e->getTraceAsString() )
    		&& false !== strpos( $trace, 'acf_get_posts(Array)' )
    		&& (
    			   (   is_admin() && false !== strpos( $trace, '->render_field(Array)' ) )
    			|| ( ! is_admin() && false !== strpos( $trace, '->format_value(' ) )
    		)
    	);
    
    	if ( $is_acf_get_posts && pll_is_not_translated_post_type( $wp_query->get('post_type') ) ) {
    		pll_remove_language_query_var( $wp_query );
    	}
    }, 9 );
    
    function pll_is_not_translated_post_type( $post_type ) {
    	global $polylang;
    
    	if ( isset( $polylang ) ) {
    		$pll_post_types = $polylang->model->get_translated_post_types( false );
    
    		return ( is_array( $post_type ) && array_diff( $post_type, $pll_post_types ) || in_array( $post_type, $pll_post_types ) );
    	}
    
    	return false;
    }
    
    function pll_remove_language_query_var( &$query ) {
    	$qv = &$query->query_vars;
    
    	unset( $qv['lang'] );
    
    	if ( ! empty( $qv['tax_query'] ) ) {
    		foreach ( $qv['tax_query'] as $i => $tax_query ) {
    			if ( isset( $tax_query['taxonomy'] ) && 'language' === $tax_query['taxonomy'] ) {
    				unset( $qv['tax_query'][ $i ] );
    			}
    		}
    	}
    }
    

    I made this filter very verbose just to make sure the idea is understand. I’m using a much more compact version in my project. This function can also be easily translated to your multilingual-plugin flavour (e.g., WPML).

    Cheers,

  • Hi @arb4host

    Yes, you could add a taxonomy field to the form. Make sure to turn on the sync in the taxonomy field options.

  • Hi, thanks so much for this. Helped a lot! But I need some help here, please.

    I want my title to have not only the ACF field value, but also the custom taxonomy I’ve created called “pico”. When I run this code,

    function my_acf_update_value( $value, $post_id, $field ) {
    	
      $terms = wp_get_post_terms($post_id, 'pico');
    
      $pico = false;
      foreach($terms as $term)
      {
          if($term->parent)
          {
              $parent = get_term($term->parent, 'pico');
              $pico = $term->name;
              break;
          }
      }
      //Default to first selected term name if no children were found
      $pico = $pico ? $pico : $terms[0]->name;
    
    	$new_title = $pico . ' - ' . $value;
    	$new_slug = sanitize_title( $new_title );
    	
    	// Update post
      $my_post = array(
          'ID'           => $post_id,
          'post_title'   => $new_title,
          'post_name'		 => $new_slug,
      );
    
    	// Update the post into the database
      wp_update_post( $my_post );
    	
    	return $value;
    }
    
    add_filter('acf/update_value/name=data_do_boletim', 'my_acf_update_value', 10, 3);

    it gives me these error messages:

    Notice: Undefined offset: 0 in /Users/Mauricio/Sites/RicoSurf/wp-content/themes/ricosurf/functions.php on line 219

    Notice: Trying to get property of non-object in /Users/Mauricio/Sites/RicoSurf/wp-content/themes/ricosurf/functions.php on line 219

    Warning: Cannot modify header information – headers already sent by (output started at /Users/Mauricio/Sites/RicoSurf/wp-content/themes/ricosurf/functions.php:219) in /Users/Mauricio/Sites/RicoSurf/wp-includes/pluggable.php on line 1196

    But when I go back and see that post, the title is perfect, exactly the way I want.

    So I assume the code “is working” just not 100%. Can some one help me find out what’s wrong?

  • OKAY, I looked even further and got more confused, the ACF field groups page states this on the right hand side:

    for version 6.1.8.1

    Advanced Custom Fields 4.1.8.1
    Changelog
    See what’s new in version 4.1.8.1

    going to the link on the page goes to here:

    Welcome to Advanced Custom Fields 4.1.8.1
    Thank you for updating to the latest version!
    ACF 4.1.8.1 is more polished and enjoyable than ever before. We hope you like it.

    What’s New Changelog
    Changelog for 4.1.8.1
    Select field: Revert choices logic – Learn more
    CSS: Revert metabox CSS – Learn more
    Core: Fixed save_post conflict with Shopp plugin – Learn more

    for version 4.4.1

    Advanced Custom Fields 4.4.1
    Changelog
    See what’s new in version 4.4.1

    and going to the link goes to here:

    Welcome to Advanced Custom Fields 4.4.1
    Thank you for updating to the latest version!
    ACF 4.4.1 is more polished and enjoyable than ever before. We hope you like it.

    What’s New Changelog

    Changelog for 4.4.1

    Taxonomy field: Added compatibility for upcoming ‘term splitting’ in WP 4.2
    Taxonomy field: Major improvement to save/load setting allowing for different values on multiple sub fields
    Core: Minor fixes and improvements

    so, it looks like the 6.1.8.1 is really 4.1.8.1 and i need to upgrade, but it does not say I need to.

  • @rustamaha – this might be a little late for you now, but you can select just one category by selecting Post Category, rather than Taxonomy Term.

    Selecting Categories

  • This reply has been marked as private.
  • I’m very interested in this feature, too!

    I tried a lot of code found in this support forum (i.e. this), and elsewhere (i.e. this, and this) so far with no luck.


    @hayatbiralem
    : thanks for your help! However, editing the plugin’s core files is not future-proof (whenever the plugin gets updated, you’ll lose your custom code).

  • Hi Steven,

    Thanks for your response. I got that far already, my custom taxonomy (‘type of film’) shows up fine in the dropdown list but what i’m trying to do is limit the field group to one specific term (‘feature length’) within the taxonomy. Is that possible?

    Thanks again

  • You can by setting up a Custom Field Group and then for that group set it so the Rules are as follows:

    Post Taxonomy, Is Equal to, Then choose your custom taxonomy from the drop down.

    If your custom taxonomy doesn’t show in the list, then It could be that the Custom taxonomy isn’t public, or isn’t searchable.

    Try changing these options and see if it shows in the list.

    Let me know if this helps

    Thanks,
    Steven Costello
    Costello Coding

  • Hi Dan,

    Check out this tutorial for getting values from a taxonomy term: http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/

    Basically, you have to pass a second argument which is a string containing the term’s taxonomy and ID in the following format: "{$term->taxonomy}_{$term->term_id}"

    Your code will be something like this:

    $term_string = '<your term string>';
    $term = get_field('staff_member', $term_string);
    
    if( $term ): ?>
    
    	<h2><?php echo $term->name; ?></h2>
    	<p><?php echo $term->description; ?></p>
    
    <?php endif; ?>

    Check out the taxonomy field documentation for more info on this. Here is the link: http://www.advancedcustomfields.com/resources/taxonomy/#template-usage

    Hope this helps 🙂

  • Hi,
    Sorry to bring up an old thread but I am using this code and it works well for standard text fields but I am trying to change the title to a Taxonomy field. The problem is that it changes my title to the ID and not the taxonomy name. Any ideas on how I can get it to display the name?

  • Can anybody help me out with some Javascript for this? I have a taxonomy field called type with options Haus & Wohnung. If value== House it should be show a select field . If value== Wohnung another select field.

  • Ok I figured it out, use Taxonomy field as single value… It was obvious, sorry, a bit tired I think.

  • just to get sure: you have no problem to show the gallery at the taxonomy page?
    but you wish to show only the first image from that gallery?

    have you try something like that?:

    <?php 
    $images = get_field('gallery_images');
        if( $images ){ 
            $image_1 = $images[0]; 
    }
    ?>
    <a href="<?php echo $image_1['url']; ?>">
     <img src="<?php echo $image_1['sizes']['large']; ?>" alt="<?php echo $image_1['alt']; ?>" />
    </a>
  • I haven’t played with it yet, but recently discovered this plugin as well. I’m researching for a project that will require front end ‘profile’ management with custom fields. I was considering syncing each user with 1 custom post.. but that feels so difficult. I’d much rather just have a custom taxonomy for users. Gonna have a play with this one soon.

  • Hello, I wonder how to create new taxonomy in my front end. I saw that it is available in WordPress admin, but not on the front page end!

    Thanks

Viewing 25 results - 2,551 through 2,575 (of 3,191 total)