Support

Account

Home Forums Search Search Results for 'taxonomy'

Search Results for 'taxonomy'

reply

  • I didnt understand your reply.

    I can already search any of those advanced custom fields set up the the ACF Pro plugin in the main search on wordpress. This was achieved by setting up the fields and setting the taxonomy as Product Visibility and then installing the plugin: “ACF: Better Search”

    So in one of the ACF fields I have dates, if I enter a date from one of those fields in the main search it will find the product that has that date in the ACF field.

    I now wish to refine that search to be able to check for searches that also match the search keyword plus the advance custom fields that I set up.

    Avada Support told me that it was possible with your plugin:
    “Every search parameter like category/tags has to be a taxonomy. For this to work, you will need to add custom taxonomies via a plugin like ACF”

    But they dont offer support in how to do it, which is why im asking here

  • Do you plan to use a new CPT to show animals instead of WC? Allowing them to continue editing in WC and using another CPT would mean you’d need to duplicate all of the existing posts and also duplicate and/or update the related CPT every time something is added/edited/deleted. This really would be more work than just building a new site.

    You could replicate most of it, but you can’t replicate the WC attributes without a lot of work. WC is special in that each “Attibuted” is a taxonomy that is created on the fly in the admin. They are basically nested taxonomies. Each “Term” in the “Attributes” is actually a custom taxonomy and attribute value is a term in the custom taxonomy.

    I hate to be the bearer of bad news but the only way to move out of WC would be to build a new site. I imagine that whoever built this used WC to reduce the amount of work that would be needed or that they were not able to do all the custom coding that would be required.

  • There is no automated way to move the data from one to the other.

    Data is stored in the _termmeta table by the term_id. When you create a new “category” this is a new term with a new term_id even if the name/slug is the same as the original “tag”.

    Moving the data would require doing an DB search for all the _termmeta connected to the old term_id and replacing it with the new term_id.

    You could, potentially, use the WP create_term hook. In the hook you could search the tags for a matching slug and then copy all of the ACF fields using get_field() and update_field(). Note that you will need to use the field keys to do the update process and NOT the field names.

  • 
    add_filter('acf/format_value/field_name=YOUR_FIELD_NAME_HERE', 'YOUR_FUNCTION_NAME_HERE', 20, 3);
    YOUR_FUNCTION_NAME_HERE($value, $post_id, $field) {
      $terms = wp_get_post_terms($post_id, 'YOUR_TAXONOMY_HERE');
      if (!is_wp_error($terms) && !empty($terms)) {
        foreach ($terms as $term) {
          if (get_field('YOUR_FIELD_NAME', $term)) {
            $value = get_field('YOUR_FIELD_NAME', $term);
          }
        }
      }
      return $value;
    }
    
  • When you are editing the “location” post can you see both your ACF taxonomy field and the default WP taxonomy meta box? Are you using “Save” and “Load” terms?

    Please provide more detail.

  • ACF currently does not allow field groups locations by taxonomy term. The ACF Advanced plugin Pro version has this. It is often requested. I would suggest contacting the devs to add this feature https://www.advancedcustomfields.com/feedback/

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

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