Hello,
I have a custom post type, with a custom taxonomy (services). I need to assign a price to each service, that is unique, per post.
I created a group on the post type, where the field names match the names of the taxonomy term that I would like to display them next to.
Then on the front end I am trying list the services, with their unique price.
I have tried doing this, but I get ‘Warning: Undefined array key’
<?php
$prices = get_field('service_prices');
$service_name = strtolower(str_replace(' ', '_', $service->name));
if ($prices):
?>
<div>
<?= $prices[$service_name]; ?>
</div>
<?php endif; ?>
How would I successfully go about doing something like this? My $service_name is outputting the correct ACF field name.
Hello,
I have a custom post type, with a custom taxonomy (services). I need to assign a price to each service, that is unique, per post.
I created a group on the post type, where the field names match the names of the taxonomy term that I would like to display them next to.
Then on the front end I am trying list the services, with their unique price.
I have tried doing this, but I get ‘Warning: Undefined array key’
<?php
$prices = get_field('service_prices');
$service_name = strtolower(str_replace(' ', '_', $service->name));
if ($prices):
?>
<div>
<?= $prices[$service_name]; ?>
</div>
<?php endif; ?>
How would I successfully go about doing something like this? My $service_name is outputting the correct ACF field name.
I have a problem with filtering posts by categories (field type: taxonomy), how can I target category/name? I attached the screens from graphQL discord where I first posted this question but they send me to “graphQL scheme creator”, please help !
I used the Jet Engine plugin to construct the taxonomy for my event post. After that, I generated the frontend form using the frontend admin and the ACF field group using the ACF plugin.
I didn’t see the “toggle all” option while creating the ACF field group. I have a taxonomy ACF field with a checkbox appearance type; however, I haven’t seen the “toggle all” option for this field. I need to “toggle all” options for this field.
Hello,
I use 2 fields in a repeater (a taxonomy and date)
I would like the taxonomy terms to be grouped together so that they list the dates associated with it.
Like this: Term_1_ : term_1_date 1, term_1_date 2 , ect…
I’ve made a classic WP foreach to retrieve taxonomy terms.
How insert date values associated with the term.
<?php if( have_rows('lieux_&_dates_en_presentiel') ): ?>
<?php
// Termes de taxo
$lieux = get_terms( array(
'taxonomy' => 'lieu-de-formation',
'hide_empty' => true,
) );
foreach ($lieux as $lieu) {
$lieu_de_formation = $lieu->name;
$lieu_de_formation_slug = $lieu->slug;
?>
<h4><?php echo $lieu_de_formation ;?></h4>
<?php }
?>
<?php endif; ?>
Is it possible with ACF ?
ACF field type is taxonomy, and appearance type is a checkbox, but I haven’t seen the “toggle all” option for this field. I really required toggle all option for this field.
I have a post object [Team] that filters for a CPT [Team Info], a category[Boys’ Soccer] and a Taxonomy [2024-25]. It works on the back end, but not the front. Do post objects not work on the front end?
Hello everyone.
I urgently need help and am looking for an ingenious idea for the following problem: How can I retrieve ACF information for variable products when exporting orders from Woocommerce?
Details:
> Orders should be exported from Woocommerce with the plugin “WP ALL EXPORT PRO” and ACF to my fulfillment partner as XML
> ONLY relevant orders or products with necessary information should be filtered, which works well for “simple products” with the following code
> Variable products (T-shirts) are also correctly recognized and exported by the code – BUT all ACF information remains empty and is not retrieved
What have I created?
> Created variable product “T-SHIRT” in the Woocommerce Dashboard
> Woocommerce attribute “SIZE” with the variants S / M / L / XL
> ACF field group “DDF” with desired text fields created to export the necessary ACF information later for orders (in addition to simple products also for product variants e.g. T-SHIRT, SIZE “L”)
> Field group rule: content type -> is equal to -> product
> Do I also have to apply the rule here? Taxonomy -> is equal to -> “SIZE”
Do I have to add or create other settings in ACF?
or is this only possible with ACF Pro?
->
/////CURRENT STATUS CODE IN WP ALL EXPORT
//////XML EDITOR
<?xml version="1.0" encoding="UTF-8"?>
<orders>
<!-- BEGIN LOOP -->
<order>
<commission>{Bestell ID}</commission>
<production>2</production>
<receiver>
<line1>{Shipping First Name} {Shipping Last Name}</line1>
<line2>{Shipping Company}</line2>
<street>{Shipping Address 1}</street>
<streetnumber>{Shipping Address 2}</streetnumber>
<country_code>{Shipping Country}</country_code>
<zip>{Shipping Postcode}</zip>
<city>{Shipping City}</city>
<email>{Customer Account Email Address}</email>
</receiver>
<items>
[my_get_order_items({Bestell ID})]
</items>
</order>
<!-- END LOOP -->
</orders>
/////FUNCTION EDITOR
<?php
function my_get_order_items($Bestell_id) {
// Check if the Bestell ID is valid
if (!$Bestell_id) {
return false;
}
// Fetch the order
$order = wc_get_order($Bestell_id);
if (!$order) {
return false;
}
// Initialize the string to store order details
$order_details = "";
// Loop through each order item
foreach ($order->get_items() as $item_id => $item) {
// Get the product object
$product = $item->get_product();
// Skip if there's no product associated with the item
if (!$product)
{ continue; }
if (!(
strpos($item->get_name(), 'KERAMIKTASSE') !== false ||
strpos($item->get_name(), 'BAUMWOLLTASCHE') !== false ||
strpos($item->get_name(), 'T-SHIRT') !== false))
{ continue; }
$order_details .= "**LT**item**GT**";
$order_details .= "**LT**ID**GT**" . $product->get_sku() . "**LT**/ID**GT**";
$order_details .= "**LT**produktname**GT**" . $item->get_name() . "**LT**/produktname**GT**";
$order_details .= "**LT**amount**GT**" . $item->get_quantity() . "**LT**/amount**GT**";
$order_details .= "**LT**upload**GT**" . maybe_serialize( get_field( 'upload', $product->get_id() ) ) . "**LT**/upload**GT**";
$order_details .= "**LT**size**GT**" . maybe_serialize( get_field( 'size', $product->get_id() ) ) . "**LT**/size**GT**";
$order_details .= "**LT**groesse**GT**" . maybe_serialize( get_field( 'produktgröße', $product->get_id() ) ) . "**LT**/groesse**GT**";
$order_details .= "**LT**material**GT**" . maybe_serialize( get_field( 'material', $product->get_id() ) ) . "**LT**/material**GT**";
$order_details .= "**LT**print**GT**" . maybe_serialize( get_field( 'print', $product->get_id() ) ) . "**LT**/print**GT**";
$order_details .= "**LT**variante**GT**" . maybe_serialize( get_field( 'variante', $product->get_id() ) ) . "**LT**/variante**GT**";
$order_details .= "**LT**category**GT**" . maybe_serialize( get_field( 'category', $product->get_id() ) ) . "**LT**/category**GT**";
//add options to the output
$order_details .= "**LT**Options**GT**";
$order_details .= "**LT**Option**GT****LT**ID**GT**" . "1996" . "**LT**/ID**GT****LT**Value**GT**" . maybe_serialize( get_field( 'value_115', $product->get_id() ) ) . "**LT**/Value**GT****LT**/Option**GT**";
$order_details .= "**LT**Option**GT****LT**ID**GT**" . "2489" . "**LT**/ID**GT****LT**Value**GT**" . maybe_serialize( get_field( 'value_117', $product->get_id() ) ) . "**LT**/Value**GT****LT**/Option**GT**";
$order_details .= "**LT**Option**GT****LT**ID**GT**" . "2056" . "**LT**/ID**GT****LT**Value**GT**" . maybe_serialize( get_field( 'value_118', $product->get_id() ) ) . "**LT**/Value**GT****LT**/Option**GT**";
$order_details .= "**LT**/Options**GT**";
$order_details .= "**LT**/item**GT**";
}
return $order_details;
}
?>
->
Does anyone have an idea?
Many thanks.
I have a content type called testimonial and this holds testimonials for 4 different services. I have created 4 pages each of which describes 1 service and it’s my aim to output the testimonials for each service on the relevant service page. I need to tie the two together. My thought process is to created a taxonomy for each service, add this field to the page and also the testimonial page. I can then do a lookup within the wordpress loop for the relevant term. Is that the best plan?
I have created a custom post type, let’s call that Services.
I have also created a custom Taxonomy called Services type
Now, I’d like to create a custom URL for the cars so it’s domain.com/services/service-type/{service name}
Where, services= custom post type, service-type = custom taxonomy and service name = the specific post name.
By default it’s domain.com/services/{service name}
How can i add taxonomy before service name ?
I use a custom post type and a custom taxonomy that is applied to this custom post type. This post type is published by receiving submissions from the front-end and the taxonomy ID value is determined at the time of form submission (the form is using another plugin called “Forminator” for this process).
However, when I checked this submitted post, the taxonomy was not applied to the post. When I go to edit the submitted post directly from the WP admin panel, the taxonomy checkbox panel is already checked with the same taxonomy as the taxonomy ID value received upon form submission, but it is not applied until I update the post (without any changes). In other words, if I update the post manually on the post editor page without any changes, everything works fine.
I found some forum threads about this and similar issues and tried disabling the Gutenberg editor, but it didn’t fix it.
Why is this happening and is there any way to fix it?
Hi,
I’m creating a generic load more system in a website for one of my client.
The configuration of the system is done by ACF fields in a custom block. The global functioning is as follow:
In the block settings you can:
In a page context, I have no issue. I send the page ID to the back and get_fields() works like a charm to force the desired configuration and return the new posts to load on front.
But where I have an issue, it’s in a FSE template context.
When I create a template for a taxonomy archive in the FSE Editor, ACF seems to save the fields value in the template’s post_content. And in this contexte I cannot fetch the fields values via get_fields() on back. I tried sending the get_the_ID(), get_queried_object_id(), etc. Nothing. ACF cannot recover the fields set in the FSE template.
Is there a way to do this? As I do not want to send the post-type / taxonomy via ajax (and thus stored in the DOM) for security issues.
Thank you.
Hi,
I need some help because I’m trying to setup a page with joboffers and selectable companies where a company might have more than one location.
I’ll try to explain my problem:
I have a custom post type “Jobs”.
I have a custom post type “Companies”.
Some Companies will have multiple locations.
I did setup field group (jobfields) with a relationship field for the post type filter “Companies” so that a company can be assigned to a job.
But now, after assigning a company to a job it should also be possible to select locations out of the locations which are assigned to that company that is selected in the relationship field.
I would like to have a possibility to assign locations to the custom post type “Company”.
Than when adding a job and selecting one company I would like to have the possibility to select only locations which are assigned to the selected company.
In the end there should be a job assigned to company and assigned to selected locations.
I don’t know if I should setup the locations as terms of a taxonomy called “locations” which can be assigned to the companies.
I tried that but couldn’t get it working that only the assigned locations from a company are shown to select. I always had all locations to select from.
Or is it better to have another custom post type e.g. “locations” which can be assigned with another relation field in the company post type. But than I don’t know how to setup the fields for that.
I’m sorry if it sounds a bit confusing but I hope someone gets my point and have an idea how to get this done.
Created a new post_type: instrument;
Created a new taxonomy: instrument-name
I added several different categories A, B, and C in the name, and then set A as the superior category of B.
Afterwards, I opened it to view all categories,/wp-admin/edit-tags.php? taxonomy=instrument-name&post_type=instrument, I can’t see B anymore. If I click sort by name, B will be displayed, but there is no subcategory flag “-” in front of B. From the HTML source code, any subcategory under the category I created with ACF that is class=”level-1″ will not be displayed. These issues are normal in the default article classification directory of WordPress. May I ask if there is any solution? thank you
Hello,
If I want to list some custom-selected posts on a page, I would create a post object field on the option page and allow the user to select the posts they want to display.
What about Taxonomy Terms? For instance, if I want to display custom-selected tags from post_tag and show them on a page, is there a way to select those objects and retrieve them on the frontend? (Something you can see on a blog site a sidebar displaying a list of popular tags for visitors to select. However, I want to have them manually selected.)
Is it possible or is there any workaround?
Thanks
I’ve set up an ACF post type called “encyclopedia” with a taxonomy category called “topics.” I now want to create an Elementor search results page that will only show post types of “encyclopedia” with the category of “topic.” I’ve tried making a PHP filter to restrict results to that criteria, but it’s still showing all entries that contain the entered search term from across the entire site.
Below is the code to show any encyclopedia entries that meet the search criteria, but it’s showing all entries that contain the entered search criteria.
Any suggestions for what I need to do differently?
Thanks in advance for your help.
if (!is_admin()) {
function mv_search_filter($query) {
if ($query->is_search) {
$query->set('post_type', array( 'encyclopedia' ));
}
return $query;
}
add_filter('pre_get_posts','mv_search_filter');
}
I’ve had a site that I’ve used for a clients construction project management that has been running flawlessly with minimal maintenance for years (7-8 years).
They are logging in with custom role using User Role Editor. On the front end they have a form (built into template using acf_form() where they fill out to create a daily log. In the form are several rows of data they can enter including repeater fields. One of the repeater fields is a taxonomy field pulling in a list of subcontractors they can choose from.
Recently they are having an issue with not seeing the taxonomy field or the ability to type in to find a subcontractor. If I am logged in as myself as an admin I see this field working. I’ve also tried the User Role Switcher to switch to the client having the issue and also see the field.
So I’m kind of stumped as to why this would happen and why I can’t recreate it. This all came out of the blue recently. So not sure if some update broke something.
Thanks.
Hello there !
I’m actually working on a site with ACF PRO, and after few hours of unsuccessful research,i’m looking for some help about taxonomy :
In the wordpress back-office as an admin, while creating a CPT, which have a hierarchical taxonomy – is there is any known solution to automatically check the childs when the user check the parent ?
In this case, a few parents have more than 20+ childs , so it can really be time-consuming if user need to add every child manually.
If any of you can give me a tips, i would love take it.
Hi!
I created custom post type and added taxonomy to it. Taxonomy has custom image field in it. I create single post page with Elementor and wanted to insert dynamically the image from taxonomy that current post belongs to but Elementor can’t see the values of post taxonomy fields.
I browsed the internet and this forum, couldn’t find a proper solution. I’d be grateful if anyone has any idea how to achieve this?
Is there a way to make the Taxonomy field look like the Button Group field? I have attempted to add the class “acf-field-button-group” to the Taxonomy field – Presentation- Class section, but that did not work.
Márcio Bento
Jul 22, 2024, 8:13 AM CDT
Hi there,
I created a taxonomy that is global across all custom post types on our website. The taxonomy is ‘Languages’
We had: English, portuguese, French, Spanish, etc.
Now the client wanted to change to the native way of writing those languages: English, Português, Français, Español.
We already changed these names. However, we have a post object field that uses this taxomy. And those are still displaying the old names. How can we quickly update this so the changes take effect? (Without having to go inside one by one and hit update)
Having the option to include multiple taxonomies in the Taxonomy Field would be helpful (instead of creating a separate field for each taxonomy).
Is it possible to populate choices for the Taxonomy field type?
My use case. There are 10 Terms in the taxonomy but I only want to show specific 3 terms.
I have tried something like this
termId : termName
But it does not seem to work. Any suggestions?
Thanks
function my_acf_load_field_options( $field ) {
// Reset choices
$field[‘choices’] = array();
// Define your options
$options = array(
’31’ => ‘Term A’,
’29’ => ‘Term B’,
’44’ => ‘Term C’
);
// Add options to field choices
foreach( $options as $key => $value ) {
$field[‘choices’][$key] = $value;
}
// Return the field
return $field;
}
// Replace ‘company_nature_of_business_2’ with the actual name or key of your ACF field
add_filter(‘acf/load_field/name=taxonmoy_option’, ‘my_acf_load_field_options’);
I’m having issues adding checkbox fields with hard-coded choices (in admin).
Every time I add a checkbox and adding the choices in admin, I’m getting this error:
array_map(): Argument #2 ($array) must be of type array, int given
Checkboxes added using taxonomy field are fine.
In:
/advanced-custom-fields-pro/includes/fields/class-acf-field-checkbox.php:247
This is the code:
$args[‘disabled’] = array_map( ‘esc_attr’, $args[‘disabled’] );
($args[‘disabled’] is 0)
Here’s the field.:
{
“key”: “field_65e14ce0816cf”,
“label”: “Charts Reporting To”,
“name”: “charts_reporting_to”,
“aria-label”: “”,
“type”: “checkbox”,
“instructions”: “”,
“required”: 0,
“conditional_logic”: 0,
“wrapper”: {
“width”: “”,
“class”: “”,
“id”: “”
},
“disabled”: 0,
“relevanssi_exclude”: 0,
“choices”: {
“Country Aircheck”: “Country Aircheck”,
“Music Row”: “Music Row”,
“AMA”: “AMA”,
“Roots Music Report”: “Roots Music Report”,
“Bluegrass Unlimited Survey”: “Bluegrass Unlimited Survey”,
“Bluegrass Today Bluegrass”: “Bluegrass Today Bluegrass”,
“Bluegrass Today Grassicana”: “Bluegrass Today Grassicana”,
“Bluegrass Today Gospel”: “Bluegrass Today Gospel”,
“Singing News”: “Singing News”,
“Singing News Bluegrass”: “Singing News Bluegrass”
},
“default_value”: [],
“return_format”: “value”,
“allow_custom”: 1,
“save_custom”: 0,
“layout”: “vertical”,
“toggle”: 0,
“custom_choice_button_text”: “Add new choice”
},
I noticed all ACF fields have disabled set to zero.
Any help is appreciated.
Hi. I am trying to set a field value on a custom taxonomy term, which may be newly created. Here’s my logic:
$client_term = get_term_by( 'name', $contact['name'], 'mp_client' );
if ( !$client_term ) {
$client_term = wp_insert_term( $contact['name'], 'mp_client' );
}
update_field( 'contact_id', $contact['id'], 'mp_client_' . $client_term->term_id );
For some reason, update_field doesn’t save the value when the term is newly created by wp_insert_term. For existing terms, it works.
Why is that? I’ve tried saving using field_keys, but it makes no difference.