I intend to develop a directory for manufacturers/suppliers with Elementor/FacetWP and for this I want to use categories and subcategories according to the scheme:
Main-Category
Main-Category
-Sub-Category A
-Sub-Category A
–Sub-Category B
–Sub-Category B
Main-Category
Main-Category
Is it possible to display this with FacetWP so that you can query Main-Category, Sub-Category A and Sub-Category B each in a separate menu?
The user selects as in order:
1. Main-Category
2. Sub-Category A
3, Sub-Category B
Sorry, I am not yet a beginner and I have a few additional questions:
1. do Main-Category, Sub-Category A and Sub-Category B each need to be captured individually with CPT UI/Taxonomies or can/should one use the hierarchical structure?
2. is the taxonomy approach even the right one or would it have to be done via Advance Custom Fields (ACF)?
Is FacetWP the best select for this application or an other Filter Plugin?
Thanks
I want to modify the item equivalent to “RENAME CAPABILITIES” for custom posts in taxonomy as well.
Alternatively, I would like to override the settings using a filter hook.
Is there a way to do this currently?
Please implement the ability to select taxonomy terms in the conditional logic section. My attached illustration will better explain what I’m getting gat.
To be honest, I’m surprised this isn’t already a feature. I firmly believe, though, that implementing this will set ACF worlds apart from its competitors.
I miss features, that would work with hierarchical taxonomy depth. It is very easy to get the depth for the term – just count get_ancestors( $term_id, ‘custom-taxonomy-slug’ ) (+ 1 if you want to start from, not zero, for the top level).
For example:
Field conditional logic:
– show this field only if the term in [other-field] is level 1
Location rule:
– show this field group only on terms on top level (typically for setting up some category images for top level categories)
Field options:
– allow to select only levels higher then 1
– display only top level categories
…
…
And also working with parent/child relationship
Display subcategories of [other field with top level category] – so making dependant select boxes.
…
Hi there,
I have some struggles with a custom Taxonomy field (coach_thema) with checkboxes. I added this field to a custom post. But when i try to get the data out of this fields, i only got to see the ID’s. I have tried a lot of things I found online, but could not find any solution. Also changing the return value doesn’t work. When i try this, it seems the whole script (of the coaches-content-page.php screenshot) crashes.
I also use a filter plugin (filter everything), which will filter on the ‘coach_thema’ field. Also here only the ID will show up. It seems the field name is not saved, or something like that.
Is there any fix for this?
Here you can find some screenshots of the situation: https://postimg.cc/gallery/DSqM6tj
I’m working with the latest version of ACF and WordPress.
Hope there is a solution.
With kinds regards,
Kasper
Hi,
I have a page (rendered using the taxonomy-{slug}.php template, based on archive.php) that displays all posts allocated to a term within that taxonomy. I would like to add a filter to it based on a custom checkbox field. I have followed the instructions in the documentation; the checkboxes display on the frontend, the URL updates accordingly when checking a checkbox but the query does not update and filter the posts. After some debugging I’ve noticed that !$query->is_main_query()
always returns true, thus not proceeding with the rest of the function. How can I get this to work on this custom taxonomy page? I also had the same result on a custom post type archive (archive-{post_type}.php) despite copying the exact same code from the documentation, only changing the field key (field name) and field name (field label).
Thanks in advance 🙂
The taxonomy field offers an option to create a new term (“Create Terms”).
When using this feature, it’s possible to insert the name of the term. But it would be very useful if it is possible to insert values for the configured custom fields for that taxonomy as well.
Per example: we have a taxonomy for which we configured a image field. When creating a new term using the Taxonomy field, we can only insert the name for the term (see attachment). For adding the image, we will still need to navigate to the term and add the image manually, this feels unintuitive.
The ability to use the custom fields right away, would be extra useful (or arguably actually a necessity) when a taxonomy has custom fields that are configured as “required”.
When we are depending on required custom fields for a taxonomy, we feel forced to disable the “Create Terms” option because the user is not able to insert values to the custom fields.
We have a field that is type “Post Object”. Prior to updating ACF Pro, we could attach scheduled posts to it, but now when we search posts it appears to only search published post statuses.
Here is some more information about our specific settings for the field:
“Filter by Post Type”: (a custom post type we created)
“Filter by Post Status”: (empty)
“Filter by Taxonomy”: “All taxonomies”
“Return Format”: “Post ID”
“Selected multiple values”: (checked)
All validation and conditional logic are default for this field type.
WP version: 6.2
Any help would be appreciated! For now, we’ll probably have to briefly publish the post in question, attach it to the field, and then re-schedule it.
Thank you!
I am not sure if I am posting in the right place as this is the first time I have used ACF and the forum. Move the post if you need to.
The setup:
I have a list of consultants that are representatives (Reps) for various territories in the US. I have already set up a basic custom form that entails the following:
Name (page title)
Territory:
Phone:
Email:
I Have about 20 pages of states already built and I am able to query the correct Reps to show on each of the state pages respectively.
All works fine but the issue is with Territory in which I have a few Reps that has 3 different territories. They are: Indiana, Tennessee and Ohio. I don’t want to list all three states at once or as one single output. I want it to display accordingly so if I land on /indiana/ page, it will just show the Territory of ‘Indiana’. If on a /tennessee/ page, it should show just the ‘Tennessee’ text, and so forth.
I hope I am making sense. I did look into ‘True/False field but I don’t know if I am doing it right as I have never done it before. I don’t mind doing the work but if there is a good tutorial that can teach how I can make happen, that would be great.
Thank you.
Hello all,
Long time user of ACF Pro and I am a little stuck trying to think through how to do this.
I have created a Custom Post Type and I am using ACF for displaying individual elements of a post (cpt post) like image, name, etc. The goal is to use Slick Slider to display these in a carousel and then use buttons outside of the Slick Slider to filter the selected categories to show specific posts in the slider. This is for a museum showing people in a hall of fame, so it would be showing everyone, then you can tap the categories to filter down to specifics, like culinary folks, business folks, women, etc.
I have created the arguments to display the posts and Slick Slider elements. Where I am lacking is making this dynamic. Here is an example of how Slick’s filtering works: https://codepen.io/chiz-developer/pen/ybxBKy and we want it to work just like this, but the colors you see here dynamically from selections made on an ACF field on the page that this is all going to be displayed on. Below is my code so far.
<section class="row">
<?php
$slider_args = array(
'post_type' => 'inductees',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DSC',
// 'tax_query' => array(
// array(
// 'taxonomy' => 'inductee_categories',
// 'field' => 'slug',
// 'terms' => 'Women'
// )
// )
);
$slider_query = new WP_Query( $slider_args ); ?>
<div class="kiosk-screen">
<?php if( $slider_query->have_posts() ){
while( $slider_query->have_posts() ){ $slider_query->the_post(); ?>
<div class="kiosk-individual">
<img src="<?php the_field('photo_2'); ?>" class="img-fluid">
<div class="card-body">
<h5 class="card-title"><?php the_field('first_name'); ?> <?php the_field('last_name'); ?></h5>
<p class="card-text"><?php the_field('graduated_hs'); ?></p>
</div>
</div>
<?php }
} else { ?>
<p>No inductees found.</p>
<?php } wp_reset_postdata(); ?>
</div>
<div class="row">
<div class="filtering">
<?php if( have_rows('categories') ): ?>
<?php while( have_rows('categories') ): the_row(); ?>
<ul class="filter">
<li data-filter="<?php the_sub_field('inductee_category'); ?>" class="<?php the_sub_field('inductee_category'); ?>"><?php the_sub_field('inductee_category'); ?></li>
</ul>
<?php endwhile; ?>
<?php endif; ?>
</div>
</section>
Hi everyones,
I deal with an issue that i can’t fix. and i’m pretty sure the solution is close.
So i need your help !!!
Here is the context:
I use acf taxonomy field to associate a custom taxonomy terms (a brand name) to a post (a product).
– The acf taxonomy field is call “brand” and as the “create terms” option checks. the taxonomy select in the acf admin panel is a custom taxonomy call “detail”
– This custom taxonomy call “detail” is hierarchical and contains many terms (parent and child). One of this terms is name “ours brands” (term_id 89) and his childs are all the brands that the store sell.
I use the “acf/fields/taxonomy/wp_list_categories” filter to display in the acf taxonomy field call “brand” only the childs of taxonomy terms “ours brands” (see code below)
function my_acf_fields_list_query( $args, $field ) {
if($field['_name'] == 'marque'){
$args['include'] = get_term_children( 89, 'detail' );
$args['orderby'] = 'name';
$args['order'] = 'ASC';
}
return $args;
}
add_filter('acf/fields/taxonomy/wp_list_categories', 'my_acf_fields_list_query', 10, 2);
Everything works fine. The field display only the brand childs as i want.
My issue is this:
When a backend user add a product of a brand that is not already exists in db (ie in “ours brand” term childs). He have to create it.
To create this new brand term, after clicking the “+” button to open the create terms panel, and tape the name of thenew brand, the user have to choose the parent of the new terms in a huge (huge, huge) list of parent and child.
It will be a source of westing time and errors.
So here comes my question:
Is there a way (filter or else), which allow to
– pre-select the parent field in the “create terms” admin panel based on the acf field that we edit
and/or
– change/customize the values (name, slug and parent) of the new term, after the create form sends (and before the new tem is save on db)?
All ideas are welcome.
Thanks for reading,
have a nice day!
Nauar
Hi
I have setup an ACF field group with multiple fields (Text and Taxonomy). I want to show the value of a field in the product (WooCommerce).
With the text fields, it works like this:
get_field('myfield')
But with the taxonomy fields, I just get the ID of the attribute.
How can I display the value set in the product on this attribute instead of the ID?
The backend “plus” button to create terms when editing a Taxonomy field is no longer appearing for me since I updated the plugin. I can see it is there in the code, but it is invisible and un-clickable. I really need this to be visible, what can I do?
Thanks
I have created a group of fields
I then set the content type = “Fieldgroup title” in the location rules. Then I created some custom post type files with these fields.
When I want to display these fields in the Templetes or in the Single Pages, only the Customer Post Titles and the taxonomies appear, but no fields are displayed. (also in Elementar)
I hope I have expressed myself clearly.
Can someone help me?
Many thanks
Hi,
For a custom post type, I’ve created a text field named “year”. Now, I need to use this field for a function which needs taxonomy. So I created a taxonomy (“years”). Is it possible to migrate ACF text field to taxonomy and populate it in each post? Thanks for any suggestion.
Best regards.
I created several custom taxonomies for attachments post-type. With ACFPRO I added fields to add/remove terms to an uploaded media file’s custom taxonomies..
The media edit page does show the ACF fields. However when I save, the terms are not stored. The page reloads without saving anything.
The ‘save terms’ toggle is in the on position in ACF edit page.
Is there anything I can do to force the saving of terms to a custom taxonomy for media?
Hi,
My company is exploring using wordpress as a Digital Assets Management solution. Our needs are not too complex, so I think this is doable.
My main questions is, can one create taxonomies for images? Can ACFPro be used for this?
We won’t be creating posts or pages. Just uploading images to the media library, where we hope to classify them in categories. For instance, shape (heart, pear, square, round, etc.), metal (platinum, gold, etc.), style (vintage, modern, etc.).
Any advice is greatly appreciated.
Hi,
In our WooCommmerce store we have a custom taxonomy called Brand. Under the Brand taxonomy there is an ACF field called Shipping Time.
I would like to create another Shipping Timem ACF for WooCommerce products and populate it’s default value from the assigned brands Shipping Time ACF field.
Is that somehow possible?
Hello, I want to insert an image that is saved in one of my custom taxonomies on a single post.
I’ve created custom post types and custom taxonomies with CPT UI. I’m displaying those custom post types each on a single post. Those posts have the taxonomy added to them.
Now I’ve given some of those taxonomies images, in a field that I have created with advanced custom fields.
I can display those images on the category side for each texonomy with the simple “image” block in elementor, when setting it to acf image field.
Now I want to display these image on some of my single post pages, that have the right taxonomy assigned to them. How I’m gonna do that? the image block with acf image field doesn’t seem to work.
Sorry if my question is unclear, I can’t describe it any different
Thanks in advance
Good morning
I am trying to get this code to work. He should normally add an option to the localization rules to the acf field. This code works when I only use functions but as soon as I transform it into a class I have critical errors. I don’t understand why, can you help me?
P.S: I specify that I enter these codes on snippets.
Thank you in advance
// Définition d'une nouvelle classe de règle de localisation ACF
class ACF_Location_Post_Category_Ancestor extends ACF_Location {
// Initialisation de la classe avec un nom, un libellé et une catégorie de règle
public function initialize() {
$this->name = 'post_category_ancestor'; // Nom de la règle de localisation
$this->label = __("Une catégorie du produit", 'acf'); // Libellé affiché dans l'interface d'administration
$this->category = 'Publication'; // Catégorie de règle (utilisée pour l'organisation des règles dans l'interface d'administration)
}
// Fonction pour récupérer les choix disponibles pour la règle
public function get_values($rule) {
// Récupération de toutes les catégories de type 'product_cat'
$terms = get_terms(array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
));
$choices = array();
if (!empty($terms)) {
// Ajout des choix en format 'value' => 'label'
foreach ($terms as $term) {
$choices[$term->term_id] = $term->name;
}
}
return $choices;
}
// Fonction pour vérifier si la règle correspond à la situation actuelle
public function rule_match($rule, $screen, $field_group) {
$terms = array();
if (array_key_exists('product_cat', $rule['value'])) {
$terms = $rule['value']['product_cat'];
} else {
return false;
}
// Si aucun terme n'est sélectionné mais un ID de post est fourni, on récupère les termes associés au post
if (empty($terms) && isset($field_group['post_id'])) {
$post_id = $field_group['post_id'];
$terms = wp_get_post_terms($post_id, 'product_cat', array('fields' => 'ids'));
}
$ancestors = array();
// Pour chaque terme sélectionné, on récupère tous les ancêtres et on les ajoute à un tableau
foreach ($terms as $term_id) {
$ancestors = array_merge(get_ancestors($term_id, 'product_cat'), $ancestors);
}
$ancestors = array_unique($ancestors);
$match = false;
// On vérifie si les termes correspondants à la règle sont présents dans les ancêtres
foreach ($rule['value']['product_cat'] as $term_id) {
if (in_array($term_id, $ancestors)) {
$match = true;
break;
}
}
// Si l'opérateur est '!=' on inverse le résultat
if ($rule['operator'] == '!=') {
$match = !$match;
}
return $match;
}
/** Charge les choix possibles pour la règle
* @param array $field Les paramètres du champ
* @return array Les paramètres du champ mis à jour
*/
// Fonction pour charger les choix possibles pour la règle
public function load_field($field, $rule) {
$field['choices'] = $this->get_values($rule);
return $field;
}
}
// Ajoute la règle de localisation dans les choix possibles
add_filter('acf/location/rule_types', function ($choices) {
if (!isset($choices['Publication']['post_category_ancestor'])) {
$rule = new ACF_Location_Post_Category_Ancestor();
$choices['Publication'][$rule->name] = $rule;
}
return $choices;
});
// Ajout des opérateurs
add_filter('acf/location/rule_operators/post_category_ancestor', function ($choices) {
$choices['=='] = __("a pour ancĂŞtre", 'acf');
$choices['!='] = __("n\'a pas pour ancĂŞtre", 'acf');
return $choices;
});
// Fin du code.
Not sure if it’s possible or if I’m missing a setting or something, but with the new post types/taxonomies feature in 6.1 I don’t see where I can set “meta_box_cb” to false for a custom taxonomy. The “Admin Editor Support” option removes the metabox but it also removes the menu item, which I still want to have.
I need your help, because, I can’t add new fields or edit existing fields with relational type (or relationship type or page_link type) in ACF group settings (post type = acf-field-group) due to values of taxonomies terms in the dropdown list..
Indeed, in my database I have a lot of entries in database for some taxonomies name (+ 200K) and when the dropdown list is loading inputs results in the memory overflow (PHP Memory limit is exceeded) and AJAX queries results in an HTTP 500 internal error.
I don’t find the good way to customize the rendered of the field “Filter by Taxonomy” from the ACF group page settings (this field appears when I select a relational type like “post object“, “relationship” or “page_link” in the field type).
I would like to remove some terms before renderer the dropdown list according a specific taxonomy name (in particular taxnomies names that have a lot of terms), for this, I need to change the query filter…
Solution 1 :
I’ve tried to add and implements code using these hooks :
but using these hooks I cannot customize the data in the select field for taxonomy filter…
I can only add new custom settings fields…
Solution 2 :
I found this hook in the plugin code : wp_ajax_acf/field_group/render_field_settings to customize the sections built, I have added custom functions to display data in the select according the type (p<ost_object, relationship and page_link), but this implementation works only at the creation of a new field and not when I am editing an existing field in ACF group.
Also, I don’t think this find is a good practice for future versions of the plugin (this is was not documented in the official documentation) and I’m afraid that this action leads to undesirable side effects…
Another solution would be to limit the number of results in the dropdown rather than loading everything at once, but I can’t find documentation on this…
Has anyone had this problem before? Can someone help me ?
You don’t show me the taxonomy terms in the body of the email with acf_form and acf_save_post
Hi. I’ve added a custom field to the Category taxonomy and I need to display the content of the field alongside the category name in the block editor (it’s only for editors’ benefit and won’t be displayed on the front-end). This might be more of a WP question than an ACF one but I’m hoping someone has had to do something similar in the past and will know the answer. I just can’t seem to find the function that the block editor uses to render the Categories panel, so I can’t find a way to inject the ACF field.
For clarity, this is where I’m trying to display the field:
Hello. My coding experience is somewhat limited, so kindly bear with me as I try to explain my scenario.
Note that I’m using the ACF Free version at the time of this post. It’s not clear whether I can achieve what I’m looking for with this version or whether an upgrade to Pro is needed. Kindly review the scenario and advise whether this can be achieved with the free version. If not, we’ll need to upgrade.
I have created a field group that collects the following:
format: PDF or YouTube video (select one or the other) as we occasionally embed these in our posts
if format is a PDF, we’re asking for:
filesize: numberic field, with “MB” appended after
number of pages: numeric fiel
if format is a YouTube video, we’re asking for:
length: text area, limited to 8 chars for hh:mm:ss
My question is this:
The conditional logic is already built in, and the above-named fields are part of a field group called “post-media-data”, with location rules as follows:
set rule to: Post Taxonomy if Category is equal to x OR … OR … etc.
I’m having trouble now figuring out:
how to add these field groups to the add new post/edit post edit screens and, subsequently, when displaying the post lists for a particular category. The intention is to allow users to see resources related to the content page (e.g., Learning about bafflegab, What is Gobbledygook, What you can do about Doublespeak):
A list of related resources might looks like this:
Each of these would link to the associated post with the corresponding media embedded in the conded as is the usual way with WordPress block editor.
Also, in which files would the PHP codes generated need to go?
I hope this is clear. I’d like contributors to have an easy method of entering this data when modifying the posts. As they may be staff or volunteers with very limited knowledge, I’d like the interface for Add/Edit post to be as intuitive as possible.