Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

reply

  • As I said in my first post, changing any ACF options based on taxonomy, make the block to disappear.
    So yes, the trick of selecting the category and updating the product to make ACF block appear works but it doesn’t allow to do anything with it.
    Maybe the fact that my issue appears with a precise WC update and is solved rolling back to previous version plus the fact that it can be perfectly replicated will help developers to find something.

  • Thanks, John.
    If you don’t mind, I am going to ask you a dumb question, as I am still learning.
    So, a lot of time, I will google for answers related to what I want.
    Below is the solution I found after you told me to use “get_terms”.
    Instead of showing only the selected categories for the post, it listed every single category I have created. Can you give me some clue why?

    $args = array(
      "hide_empty" => false,
      "taxonomy" => "project-category",
    );
    
    $terms = get_terms($args);
    foreach($terms as $term){
      echo $term->name.", ";
    }?>

    I hope I am not disturbing you, though.

  • you can’t use get_the_category() either. All category functions in WP and anything that has “category” in it is for the built in WP category taxonomy.

    For custom taxonomies you have to use get_terms(). This will return an array of terms that you’ll need to loop over (event if there is only one term).

  • The “catetory_name” argument for WP_Query() will only work for build in WP category taxonomy. You must use a taxonomy_query for custom.

    
    'tax_query' => array(
      array(
        'taxonomy" => 'YOUR CUSTOM TAXONOMY NAME HERE',
        'field' => 'slug',
        'terms' => 'featured'
      }
    )
    
  • Yes, I created the custom taxonomy in ACF too.
    Below are the screenshots.
    So you can have a brief idea of what I have done.
    Thank you.

  • Like I said, I tested it.

    I created a CPT “project” using ACF. I added the built in WP category taxonomy to it. I created a “project” and added the “featured” category to it. Then I did the same query you are doing.

    Everything worked as expected.

    Did you also create a custom taxonomy?

  • The standard WP permalinks for CPT and taxonomies is

    CPT
    archive = /$post_type/
    single = /$post_type/$post_name/

    Taxonomy
    archive /$taxonomy_name/$term_slug

    Anything outside of this is beyond the ability of ACF or any other plugin that manages custom post types that is available (as far as I know) to accomplish.

    The only way to do this is by adding custom rewrite rules and custom permalink structure using WP actions and filters. It is a complicated process and more than I can explain here. Even this is going to be limited because your superstructure and rewrite rules will need to supply WP with the post type, the taxonomy, the term and the post name in order for the main query to find the correct page.

    To do this you will need to look at some or all of the following:

  • The taxonomy field has the option of using a radio button for presentation. It also has a setting that enables/disables adding terms.

    If you’re talking about the standard WP metabox for terms, ACF cannot control this. You would need to remove the default WP metabox and use an ACF field.

  • Actually, there is a solution, but I didn’t have enough time to realize it through acf, maybe this will help someone to realize this task.
    And so: on the page of creating/editing taxonomy (attribute), custom form, which has hooks:
    woocommerce_after_edit_attribute_fields – for the attribute edit page.
    woocommerce_after_add_attribute_fields – for the add attribute page.

    I can add a custom input \select \anything through this hook, and then, on the admin_init hook (for example), check $_POST and if my input is there (if my input is there, there will be other inputs from the form), save this value in the database table. You can save it anywhere, but it is more correct to save it in a custom table, and create a link, for example, by the key (slug) of the attribute, for example pa_finish. And as a result, when processing a product or a taxonomy term, we can take the slug of the taxonomy (attribute) and use it in the custom table in the database to get the value that we attached to the form of creating/editing the attribute.
    Thus, I can save primitive data, such as select to specify the type of display attribute (image \ color \ text \ select) and based on this, display the necessary html for a particular attribute.

    John Huebner – I’ve seen a lot of your posts, and I think you can do it).

  • Elementor is looking for a field on the post, this field does not exist on the post, it exists on the taxonomy term. Elementor cannot do what you are looking for.

    It this instance elementor does use the ACF function get_field(), this is not the case with all field types. Because of this you can use an acf/format_value filter with a priority of > 10 so that it runs after the built in ACF filter, to alter the value.

    In this filter you would get the terms that the post is assigned to using get_post_terms(). For the post ID your would use get_the_ID(). This will return an array of terms. The you need to loop over this array, event if there is only one, and then get and return the color from the term

    
    $return get_field('category_color', $term);
    
  • Yes, you’ll need to add some custom conditional logic, I don’t have an answer for you but you will find some solutions to start from in [FORUM SEARCH RESULTS]

  • I mostly understand this and it seems like an excellent solution.

    There is an issue I’m running into however…

    I should have mentioned the product types include both parent and child, and there can be instances where the product belongs to multiple product types.

    It seems I can only get the conditional logic to work if the Product Type has only one option selected and the Product Type Taxonomy Field is set to a single value. Radio Button or Select, not checkbox or multi-select.

    I don’t mind adding conditional logic for both a parent Product Type (A with ID 4) and a child Product Type (B with ID 5), but I can’t see how it would work…
    Product Type (field) Selection is Greater than 4 and Less than 6 isn’t returning Product Type B when both B and A are selected.

    Is there a way around this?

    “You remove the taxonomy metabox in WP by setting the “meta_box_cb” argument to false.”

    In the edit taxonomy page for the Product Type taxonomy I set Visibility->Meta Box to “No Meta Box”, but I don’t see any difference. Any clarification would be greatly appreciated.

  • Hi John,

    This is in a JS file thats being enqueued in the themes functions.php

    It’s probably easier to tell you what i’m trying to achieve.

    I have a page that loads a custom post type called projects in a isotope.js grid.
    I’ve got some filtering going on using a URL hash. EG. /projects/#tag=green or /projects/#network=bbc

    that’s all handled in javascript.

    When a tag is loaded i want to be able to pull a title & an acf field from the taxonomy term of the tag “green” and update a classes innerhtml with the loaded data.

    As far as i’m aware php can’t access the hash and java is the way to do it.

  • It is possible to achieve this without created multiple field groups and multiple fields of the same name.

    The best, easiest why to achieve this is.

    1) Instead of using the default meta boxes for assigning taxonomy terms to post you use an ACF taxonomy field in the field group.

    You remove the taxonomy metabox in WP by setting the “meta_box_cb” argument to false.

    In the ACF taxonomy field you turn on both the “Load Terms” and the “Save Terms” options.

    2) For all of the other fields you use conditional logic to determine if a field should be shown based on the taxonomy field.

    This can be a little difficult using the ACF native conditional logic because you have to check if the term ID is > or < a given value.

    Conditional logic can be extended if you want to be able to choose terms, this has been done but I don’t have any specific examples to point you to.

  • I already tried with get_queried_object() but it returned an “array to string conversion” error.

    However, I found a better solution on the following link as I needed to display multiple values : https://www.advancedcustomfields.com/resources/taxonomy/

    Thanks for your help, though.

  • $queried_object = get_queried_object(); 
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;  
     
    // load desc for this taxonomy term (term object)
    $thumbnail = get_field('category_description', $queried_object);
     
    // load desc for this taxonomy term (term string)
    $thumbnail = get_field('category_description', $taxonomy . '_' . $term_id);
    
    echo '<p class="dop_widget_p">' . get_field( 'category_description', $queried_object ) . '</p>';

    Wrap the text in a tag and add style

  • Hi

    The method is already working ?

    i tried.. and it dont work :/

    What i made :

    i got a custom field form, who search in ajax with get_users and with complexe request on many user’s customs fields

    all work fine, even filter taxonomy assigned to user like custom field

    but this dont work for my repeater field..

    the repeater key is : liste_des_langues & the item key : langue

    if add this :

    function wpza_replace_repeater_field( $where ) {
        $where = str_replace( "meta_key = 'liste_des_langues_$", "meta_key LIKE 'liste_des_langues_%", $where );
        return $where;
    }
    add_filter( 'posts_where', 'wpza_replace_repeater_field' );

    and this is my request args for this field :

    if($langues && $langues != 'all'){
            $temp = array(
                'key' =>  'liste_des_langues_$_langue',
                'value' =>  $langues,
                'compare' => 'LIKE',
            );
            array_push($request['meta_query'] , $temp);
        }

    this is the basic request :

    $request = array(
            'role__in' => array( 'consultant' ),
            'meta_query'      => array(),
            'tax_query'      => array(),
        );
    
        if(count($_GET) > 1){
            $request['meta_query']['relation'] = 'AND';
        }

    and i dont understand where is my mistake, someone can help please ?

  • I’ve got a similar problem.

    A) added taxonomy via ACF (set to show MetaBox)
    B) added custom post type via ACF

    Problem is: no categories meta box when the REST Api is off for the taxonomy.

    Why do we need the REST Api of the taxonomy to show the meta box in the edit screen?

  • You would have to remove the standard WP meta box for the taxonomy and create an ACF field to replace it in order to make selecting a term required.

  • another thing that I just thought of, you are using a group field with sub fields… You can’t update the sub field directly using update_field(). You either have to update the group field with an array of sub fields (field key => value pairs), or you need to use update_sub_field(), https://www.advancedcustomfields.com/resources/update_sub_field/

    Yes, a taxonomy field holds and array of term ID as string values.

  • The problem is worse when there are a large number of terms in the given taxonomy.

    The ACF Extended “Taxonomy Terms” field allows for disabling lazy load, making it much faster to get to the end of a long hierarchical list. Unfortunately, the ACFE Taxonomy Terms field does not include the ability for the user to add new terms.

    A taxonomy field that reproduced all of the features of the WP Core post editor taxonomy “components-panel” – including search and parent area designation among other user-friendly features – would be even better than an ACF Field that didn’t realy on lazy loading or an ACFE field that include the ability to add new terms.

  • Pods has features when adding post types and taxonomies that are not available in ACF, for example post type relationships. Replacing these features could be problematic and/or require the addition of custom code that Pods uses to accomplish these features. This may be the reason that ACF has not include it on top of the fact that most people were using CPT-UI.

    I would first make sure that I’m not using any special features that would need to be replace. That means only using the features available when using register_post_type() and register_taxonomy().

    Then you would have to delete all of the post types and taxonomies from Pods and then recreate them with ACF. Deleting a post type or taxonomy in most plugins does not usually delete the posts or the terms associated with them.

    All this being said, this is not something I would do, I don’t, as a general rule, retrofit client sites, they are what they are.

    If I did decide this was necessary I would most definitely not attempt it without making a complete backup of the site before I started.

  • Hi

    Please use below code. i think it will work for you.

    $id = get_the_ID();
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;
    $post_id = ‘product_cat_’.$term_id;

    echo get_field(‘per_round_cost’, $post_id);
    echo get_field(‘upc’, $post_id);
    echo get_field(‘caliber’, $post_id);
    echo get_field(‘bullet_weight’, $post_id);
    echo get_field(‘bullet_type’, $post_id);
    echo get_field(‘case_type’, $post_id);
    echo get_field(‘combine_reviews’, $post_id);

  • maybe they meant to post it here https://www.advancedcustomfields.com/feedback/

    but anyway, I do not understand to difference between your custom taxonomy and others. All taxonomies in WP have a “term_id” property. How is it that your taxonomy does not have this property?

  • When creating the taxonomy in ACF

    Advanced Configuration => Visibility => Show Admin Column

Viewing 25 results - 651 through 675 (of 3,193 total)