Hello everybody,
I found this
Display location address details
This is real cool.
Now I try to extract information and put it directly into my taxonomy LOCATION and CITY.
But how do I put the info $location[ ‘city’ ] and $location[ ‘state’ ] into the Taxonomies.
function my_copy_date_filter( $post_id ) {
$post_type = get_post_type( $post_id );
if ( $post_type != 'spot' ) {
return;
}
$location = get_field( 'spot_location', $post_id );
if( $location[ 'lat' ] && $location[ 'lng' ] ) {
update_field( 'spot_lat_lng', $location[ 'lat' ].','.$location[ 'lng' ], $post_id );
}
if( $location[ 'state' ] ) {
update_field( 'new_spot_state', $location[ 'state' ], $post_id );
}
if( $location[ 'city' ] ) {
update_field( 'new_spot_city', $location[ 'city' ], $post_id );
}
// HOW CAN I PUT $location[ 'city' ] and $location[ 'state' ] into taxonomy
}
add_filter( 'acf/save_post', 'my_copy_date_filter', 20 );
Any suggestion?
Thanks in advance,
Denis
I am trying to add an ACF variable to a WordPress query
I have an ACF taxonomy field (firm_types), it returns the term object.
My form is sending the term_id. I think the problem is that I am returning the taxonomy object, not specifically the term_id, somehow I need to make that the comparison
form (this displays correctly)
$terms = get_field('firm_types');
if( $terms ):
foreach( $terms as $term ):
$option .= '<option value="'.$term->term_id.'">';
$option .= esc_html( $term->name );
$option .= '</option>';
endforeach;
endif;
Search results page
$args = array(
'post_type' =>'companies',
'post_status' => 'publish',
'posts_per_page' => 100,
'meta_query' =>
array(
'relation' => 'AND',
array(
'key' => 'company_office_visibility',
'value' => "yes" ,
'compare' => '='
)
)
);
if (isset($final_architects_cat) && ($final_architects_cat != "") ) {
$args['meta_query'][] = array('key' => 'firm_types', 'value' => $final_architects_cat, 'compare' => '=');
}
$wp_query = new WP_Query( $args );
Hi,
I’m trying to achieve something that seems to be simple but I can’t figure out how.
Here it is:
I want to “link” posts seamlessly by a common field value. Let me explain :
I have two CPTs with posts. In CPT1-post1 I want to create a bidirectionnal link to CPT2-post2 (and I know how) and CPT3-post3. But I want to filter/populate the list in the post selector’s field with certain conditions :
– CPT2-post2 and CPT3-post3 share a field’s value (or a taxonomy value) and it’s activated by selecting CPT2-post2
– CPT2-post2 and CPT3-post3 are not yet linked to another post of CPT1 (exclusive relationship)
– CPT2-post2 and CPT3-post3 have a defined taxonomy value
And if you want a more concrete explanation, I want to build a system with bundles (CPT1), each bundle contains different objects (from CTP2 and CPT3 or more) that are available (not yet in a bundle) and related to the same family (aka which can be used together, aka compatible) and with a defined status. Of course I can add more than one object of CPT2 or CPT3 to a bundle.
So, do you have any idea? I’ll consider every answer even the one which require other extensions.
Thanks a lot for your interest in my question
I am trying to return the url of an icon (implemented with ACF + WPML) from a translated custom taxonomy term:
@php
$terms = get_terms(array(
'taxonomy' => 'parcours',
'hide_empty' => true,
));
@endphp
@if (!empty($terms))
@foreach ($terms as $term)
@php
$id = $term->term_id;
$taxonomy = $term->taxonomy;
$slug = $term->slug;
$name = $term->name;
$image = get_field('route_icon', $taxonomy . '_' . $id);
@endphp
@php echo $image @endphp
@endforeach
@endif
No matter what i have tried (wpml_object_id included). The image variable is empty in the translated site only. The variable is returning the expedted data in the original language and everything is working well. Also the id variable is returning the correct translated id as expected.
Am I doing something wrong in ACF? Thanks a lot for your help.
I assume this is possible, but probably with more digging into things than I’ve been able to do…
WooCommerce has a bunch of taxonomies associated with it. One is Attributes, commonly used for things like “Shirt Color”, and then under that attribute would be terms, like “Red”, “Yellow” and “Blue”. Here’s how these are represented in the backend UI:
Something seems a bit odd with the attributes, they have an edit URL like this that does not reference a post_id or anything, and the numbering starts at 1 and increments with each attribute:
wp-admin/edit.php?post_type=product&page=product_attributes&edit=1
The terms are simple, which is why I guess it’s easy to add fields there with the normal taxonomy selections in ACF:
wp-admin/edit-tags.php?taxonomy=pa_altacom-ceramics&post_type=product
(list of terms)
wp-admin/term.php?taxonomy=pa_altacom-ceramics&tag_ID=2804&post_type=product&wp_http_referer=%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dpa_altacom-ceramics%26post_type%3Dproduct
(editing an individual term)
And you can see here we use ACF to add a field for an image to each term:
Hope that all makes sense – we want to add a field not at the “term” level (we’ve already done that), but at the attribute level, which seems to be hard because Woo is doing something unique here…
Technically we could add the field to the terms, but that would mean setting a few fields on a few thousand terms, which would be kind of laborious.
Any ideas?
Hello ACF support team,
As I’m a WP developer and working on my customer websites, They have ACF pro and I’m working on them, Anyway, the problem is When loading the “Select2” JS library with Yoast Seo, The taxonomy ordering on the multi-select box not working and a Js error came up on the browser console, This issue fixed on the latest version v5.10.1 but still, the ordering not working after/before save and can’t change the taxonomies orders as a custom order when adding them into the box.
Now I downgrade them to the v5.9.9 with this custom code as I’ve written, It’s for an example and everything working well again:
// Fix Yoast SEO & ACF select2 conflict
function fixYoastAndAcf() {
if ( class_exists( 'ACF' ) ) {
wp_deregister_script( 'yoast-seo-select2' );
wp_dequeue_script( 'yoast-seo-select2' );
wp_enqueue_script( 'yoast-seo-select2', acf_get_url( "assets/inc/select2/4/select2.full.js" ), [ 'jquery' ]);
}
}
add_action( 'admin_enqueue_scripts', 'fixYoastAndAcf', 99 );
I hope this issue fix on the next versions.
Best Regards.
We’ve had no issues adding fields to WooCommerce Attribute Terms (eg: Attribute being “Color” and Attribute Terms being “red”, “blue”, “green”). We can do this in the ACF “Location” section by selecting “Taxonomy” and then “is equal to” and then choosing an attribute (like “Color”). When we edit terms for “Color” we then have a new field, in our case, an image for a color/fabric swatch.
However, we now have more than 30 Woo attributes and each attribute needs a location rule – it’s very unruly (sorry for the pun).
This would be so much easier if we could have something besides “is equal to” and “is not equal to” for the match:
Having an SQL “LIKE” would be great. We have attributes named in such a way that if we could do “LIKE” and then “%leather%” or “%marble%” or “%melamine%” we could have a much shorter list of rules and our catalog folks wouldn’t have to remember to add new rules unless they’re adding a whole new class of attributes with a new name.
Any clever way to achieve that?
Just an example showing a snippet of how many attributes are here:
Hi!
Currently, I am working on a website where I have to show posts with the category that is selected with the taxonomy field. With “normal” (single) posts, it works like a charm. To show how it works:
<?php
// get the current taxonomy term
$term = get_queried_object();
$catact = get_field('actueel_category', $term);
$loop = new WP_Query( array(
'post_type' => 'actueel',
'posts_per_page' => 2,
'category__in' => $catact,
)
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<a href="<?php the_permalink();?>">
<div class="post">
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<div class="thumbnail" style="background-image:url('<?php echo $thumb['0'];?>');">
</div>
<div class="theme__inner__content">
<h4><?php the_title();?></h4>
<span class="more">lees meer</span>
</div>
</div>
</a>
<?php endwhile; wp_reset_query(); ?>
Now, when I try to do the same with Woocommerce Products, it doesn’t work. Here is the code I use for that:
<?php
// get the current taxonomy term
$term = get_queried_object();
$catpro = get_field('product_category', $term);
$loop = new WP_Query( array(
'post_type' => 'product',
'posts_per_page' => 2,
'product_cat' => $catpro,
)
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<a href="<?php the_permalink();?>">
<div class="post">
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<div class="thumbnail" style="background-image:url('<?php echo $thumb['0'];?>');">
</div>
<div class="theme__inner__content">
<h4><?php the_title();?></h4>
<span class="more">lees meer</span>
</div>
</div>
</a>
<?php endwhile; wp_reset_query(); ?>
Is there something that I’m not getting?
In the Admin area: I use the taxonomy field, both outputs are being displayed as Term ID’s. For the regular post I’ve selected the “category” taxonomy and for the product the “product_cat” taxonomy.
Can someone think with me here? I can’t seem to solve it. Maybe I’m overlooking something.
Thanks in advance!
I’m trying to create a ACF flexible content row to display the most recent post thumbnails for a given category. However it keeps throwing a critical error and I’m not sure why.
<?php
$section_id = get_sub_field('section_id')
$categories = get_sub_field('categories');
$tags = get_sub_field('tags');
$postnum = get_sub_field('number_of_posts');
// make sure it is an array, if only one is
// selected it may return a single value
if (!is_array($categories)) {
$categories = array($categories);
}
$tags = get_field('my_tags_field');
if (!is_array($tags)) {
$tags = array($tags);
}
$args = array(
'post_type' => 'post',
'numberposts' => $postnum,
'posts_per_page' => -1,
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'terms' => $categories
),
array(
'taxonomy' => 'post_tag',
'terms' => $tags
)
)
);
$query = new WP_Query($args);
?>
<style>
</style>
<section class="post_row_with_thumbnails" id="<?php echo $section_id; ?>">
<div class="container-fluid">
<div class="row">
<?php if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
<div class="col">
<a href="<?php the_permalink(); ?>">
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?>" class="project_pics">
<h5 class="posttitle"><?php the_title(); ?></h5>
<h6 class="postdate"><?php the_date(); ?></h6>
</a>
</div>
<?php endwhile; endif; wp_reset_postdata(); ?>
</div>
</div>
</section>
I have tried substituting WP_Query() with get_posts() but it gives me the same critical error.
Hi, I’m trying to create a group field for each term attached to this custom post.
Like this:
Say my CPT is for this product: Wood Panels and this can be used for Facade, Floors and Interiors (these are the selected terms).
I need to create the field groups for each, but I tried to do this by PHP, I tried something like this:
function create_field_groups() {
global $wpdb;
// general fields
// everything goes ok here
acf_add_local_field_group(array(
'key' => 'group_1',
'title' => 'Product Data',
'fields' => array(
array(
'key' => 'field_1',
'label' => 'Product',
'type' => 'tab',
'placement' => 'top',
'endpoint' => 0,
),
array(
'key' => 'field_2',
'label' => 'Short Description',
'name' => 'product_short_description',
'type' => 'wysiwyg',
),
// etc...
),
'location' => array(
// etc...
),
));
// querying DB to get terms in taxonomy
$query = 'SELECT DISTINCT
t.name, t.slug
FROM
wp_terms t
INNER JOIN
wp_term_taxonomy tax
ON
tax.term_id = t.term_id
WHERE
(tax.taxonomy = \'my_taxonomy\')';
$terms = $wpdb->get_results($query, ARRAY_A);
// if we get terms then create group fields for this term
if ($terms) {
foreach ($terms as $term) {
$slug = $term['slug'];
$name = $term['name'];
acf_add_local_field(array(
'key' => 'field_1_' . $slug,
'label' => $name,
'type' => 'tab',
'placement' => 'top',
'endpoint' => 0,
'parent' => 'group_1',
));
acf_add_local_field(array(
'key' => 'field_2_' . $slug,
'label' => 'Short Description',
'name' => $slug . '_short_description',
'type' => 'wysiwyg',
'parent' => 'group_1',
));
// etc...
}
}
}
add_action('acf/init', 'create_field_groups');
With this function I can generate the first part of the fields, but when I try to create the terms fields instead of getting four different tabs, I just get one from the last term.
How can I fix this?
To better manage a site, I’m using an options page to centralize some options.
I’m trying to create a shipping time option with an ACF repeater.
I have three subfields..
Shipping estimate – text field
Category – taxonomy field where you can select multiple categories
Priority – a number field to set priority.
But for the front end I need a snippet to display the field.
I want to display the shipping estimate on a product (only once) if the product has one of the selected categories. It could be some categories overlap with another row I created, if so I only want the shipping estimate with of the row that contains the highest priority number.
Could someone help me along with the part to display the shipping estimate if one or more of the categories is selected and in has the highest priority number?
I’m trying to get the ACF Relationship field to list Taxonomies in the selection meta field. I’ve been looking for a solution for a while but just can’t find or figure out the code to do it. I cant use a taxonomy field here because I need the user to be able to select any post, page, etc., and in my specific case, the actual category page, to the selection.
Im not looking to filter by taxonomies as i know that is already an option.
The results for instance would then allow me to show a list from the selected posts, pages, etc., and “categories”.
for example:
– Hello world! (post)
– Things to do… (page)
– New Years Party (event / etc.)
– Biking (category)
My guess is to somehow add the categories to the arguments in a function for this specific field.
something like:
function add_categories_to_relationship($args, $field, $post_id)
{
//1: add categories pages to selection
$args['???'] = array('category');
return $args;
}
add_filter('acf/fields/relationship/query/key=field_60c258b4efd79', 'add_categories_to_relationship', 10, 3);
any help would be much appreciated.
Hi,
I added fields to a taxonomy term, but would like to display them on a single CPT. I do not know how to do it and whether it is possible at all.
I would be grateful for any help.
Regards!
Tsering
I have been using this method for quite some time. But after I updated my wordpress version to 5.8. I won’t work anymore
Looking for help.
I have built a hierarchical taxonomy for wine regions.
I created a custom page for wineries.
I created ACF group for wineries and the user starts with filling in name and address winery.
I created several taxonomies. One of them is location of the winery.
So:
Countries (e.g. France , etc) is the parent
– Regions (e.g. Provence, Bourgogne, etc.) is the child
— Wine regions (e,g. Bandol, Cote de Provence, etc.) is the grandchild
Another taxonomy is for instance for ‘appellations’. Appellations are related to wine regions 9as we all know ;).
First challenge:
Based on address (which contains country, user gets list of Regions and their Wine regions. The user only has to select the wine region. For clarity’s sake: in the editor the user doesn’t have to select Country or Region anymore.
All three (Country, Region and Wine region will be displayed in the front-end.
Country – select taxonomy*
Address/Town – location* (to be rendered in text and shown on map)
Region – select taxonomy* (shown list is based on Address/Country)
Subregion – select taxonomy* (shown list is based on Region)
How do I put this together?
Second challenge:
Also the other related taxonomies like Appellations should first look which in which country the winery is and then show the related appellations.
For instance:
if France, then AOP, AOC
if Italy, then DOG, DOGC
etc.
else (for rest of world) IG
I tried using the conditional logic but it seems I cannot use the outcome of Country taxonomy selections as argument to show other fields based on values.
If you could help me I would be very grateful.
Nicolaas
I would like to have two taxonomy fields:
This person likes…
This person does not like…
both have the same taxonomy/tags to choose from, but if one tag is already selected in one question, it cannot be selected anymore in the second.
Any idea how I can achive this?
I’m using this code to display taxonomy terms:
<?php
$features = get_field('grid_selected_features');
if( $features ): ?>
<ul>
<?php foreach( $features as $term ): ?>
<h2><?php echo esc_html( $term->name ); ?></h2>
<?php echo esc_html( $term->description ); ?>
<a href="<?php echo esc_url( get_term_link( $term ) ); ?>">View all '<?php echo esc_html( $term->name ); ?>' posts</a>
<?php endforeach; ?>
</ul>
<?php endif; ?>
The permalinks are working, but the term name is not displaying.
Hello,
I created custom taxonomy for woocommerce products ‘coffee_type’.
I created an ACF image field ‘coffee_type_image’ to this taxonomy.
I want to show the image with a link and not the name of the taxonomy on the product page.
I’ve read most articles here about showing acf image on taxonomy but every one of them is about working with the archive taxonomy page and not a product page.
I’m editing the single-product.php (content-single-prodct.php to be exact).
This is my current loop
<?php $wcatTerms = get_terms('coffee_type', array('hide_empty' => 0, 'parent' => 0));
foreach ($wcatTerms as $wcatTerm):
?>
<ul>
<li>
<a href="<?php echo get_term_link($wcatTerm->slug, $wcatTerm->taxonomy); ?>"><?php echo $wcatTerm->name; ?></a>
<?php $taxonomy = $queried_object->taxonomy;?>
</li>
</ul>
<?php
endforeach;
?>
This is the var_dump of #wcatTerm
object(WP_Term)[3704]
public 'term_id' => int 33
public 'name' => string 'coffee and chicory' (length=18)
public 'slug' => string 'coffee-and-chicory' (length=18)
public 'term_group' => int 0
public 'term_taxonomy_id' => int 33
public 'taxonomy' => string 'coffee_type' (length=11)
public 'description' => string '' (length=0)
public 'parent' => int 0
public 'count' => int 2
public 'filter' => string 'raw' (length=3)
This is the var_dump of get_queried_object();
object(WP_Post)[3316]
public 'ID' => int 671
public 'post_author' => string '1' (length=1)
public 'post_date' => string '2021-07-27 14:04:09' (length=19)
public 'post_date_gmt' => string '2021-07-27 14:04:09' (length=19)
public 'post_content' => string '<!--(figmeta)eyJmaWxlS2V5IjoiOWxOQjFWT01TaWFzVmx6cmxTUTl3YiIsInBhc3RlSUQiOjE2MjEzNjQ4LCJkYXRhVHlwZSI6InNjZW5lIn0K(/figmeta)--><!--(figma)ZmlnLWtpd2kEAAAARCMAALV7f5wsS1VfVc/M/rh7730/eTyeiIiIiKjvF+89EJGenp7dvjsz3a+7Z/beJzL0zvTuzruzM8P0zN67T0REQgxBRFQgiAQJUUSjqPgrQUVi1CSKvxERFRGNMYlJzC9jjMn3W9W/5u59fvzH+/ncqVOnTp06deqcU6eqet8m23GSRIdxeDqLhbjlkut0+kFo+qHAv47bsPvWjtnZtgNUZTew/VLdUNR2pwG4EjjbHbMFqBqEV1o2gJoC+oFNXmuKVnHuB7uO1/ftlmuy53rHDZ3mlX6w43ZbjX7X2/bNBvtvpGC/4XZY38zqvt307WAHqHOBZXfsPtDeTv/Rru1fAXKrjPRtr0Xk+Yb'... (length=52896)
public 'post_title' => string 'Product Name 1' (length=14)
public 'post_excerpt' => string '<!--(figmeta)eyJmaWxlS2V5IjoiOWxOQjFWT01TaWFzVmx6cmxTUTl3YiIsInBhc3RlSUQiOjE2MjEzNjQ4LCJkYXRhVHlwZSI6InNjZW5lIn0K(/figmeta)--><!--(figma)ZmlnLWtpd2kEAAAARCMAALV7f5wsS1VfVc/M/rh7730/eTyeiIiIiKjvF+89EJGenp7dvjsz3a+7Z/beJzL0zvTuzruzM8P0zN67T0REQgxBRFQgiAQJUUSjqPgrQUVi1CSKvxERFRGNMYlJzC9jjMn3W9W/5u59fvzH+/ncqVOnTp06deqcU6eqet8m23GSRIdxeDqLhbjlkut0+kFo+qHAv47bsPvWjtnZtgNUZTew/VLdUNR2pwG4EjjbHbMFqBqEV1o2gJoC+oFNXmuKVnHuB7uO1/ftlmuy53rHDZ3mlX6w43ZbjX7X2/bNBvtvpGC/4XZY38zqvt307WAHqHOBZXfsPtDeTv/Rru1fAXKrjPRtr0Xk+Yb'... (length=22771)
public 'post_status' => string 'publish' (length=7)
public 'comment_status' => string 'open' (length=4)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string '' (length=0)
public 'post_name' => string 'product-name-1' (length=14)
public 'to_ping' => string '' (length=0)
public 'pinged' => string '' (length=0)
public 'post_modified' => string '2021-07-31 11:57:41' (length=19)
public 'post_modified_gmt' => string '2021-07-31 11:57:41' (length=19)
public 'post_content_filtered' => string '' (length=0)
public 'post_parent' => int 0
public 'guid' => string 'http://localhost/orc/?post_type=product&p=671' (length=50)
public 'menu_order' => int 0
public 'post_type' => string 'product' (length=7)
public 'post_mime_type' => string '' (length=0)
public 'comment_count' => string '3' (length=1)
public 'filter' => string 'raw' (length=3)
How can i display inside the ACF field ‘coffee_type_image’ with a link to the archive page? I don’t know how to pass the ACF to this taxonomy to display the image
Thank you
I need to bring the information of a Post Type from a Remote URL that show a json file.
This information will be loaded into WP-Admin to allow user selection when Filling in custom fields on a page.
Sample of remote url(json)
{
"id": 1,
"nome": "Tribunal de Justiça do Estado do Acre",
"sigla": "TJAC",
"unidades": [{
"id": 2,
"nome": "Acrelândia",
"sigla": "AL",
"unidades": [{
"id": 24,
"nome": "Direção do Foro",
"sigla": "ALDFO",
"unidades": [
],
"tipo": "ADMINISTRATIVA"
},
{
"id": 25,
"nome": "Vara Única",
"sigla": "ALVAR",
"unidades": [
],
"tipo": "VARA"
}
],
"tipo": "COMARCA"
},
{
"id": 3,
"nome": "Assis Brasil",
"sigla": "AB",
"unidades": [{
"id": 26,
"nome": "Direção do Foro",
"sigla": "ABDFO",
"unidades": [
],
"tipo": "ADMINISTRATIVA"
},
{
"id": 27,
"nome": "Vara Única",
"sigla": "ABVAR",
"unidades": [
],
"tipo": "VARA"
}
],
"tipo": "COMARCA"
}
}
My Custom Fields Created in ACF
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_6100ec8d1bf79',
'title' => 'Lotação',
'fields' => array(
array(
'key' => 'field_6100f04affa8f',
'label' => 'Nome',
'name' => 'nome',
'type' => 'text',
'instructions' => 'Nome da Unidade',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => 'Nome da Unidade',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_6100f3c5ffa91',
'label' => 'Sigla',
'name' => 'sigla',
'type' => 'text',
'instructions' => 'Informar a Sigla da Unidade',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => 6,
),
array(
'key' => 'field_6100f076ffa90',
'label' => 'Comarca',
'name' => 'comarca',
'type' => 'taxonomy',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'taxonomy' => 'comarca',
'field_type' => 'checkbox',
'add_term' => 0,
'save_terms' => 0,
'load_terms' => 0,
'return_format' => 'id',
'multiple' => 0,
'allow_null' => 0,
),
array(
'key' => 'field_6100f421ffa92',
'label' => 'Tipo',
'name' => 'tipo',
'type' => 'select',
'instructions' => 'Selecionar Administrativo | Primeiro Grau | Segundo Grau',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'ad' => 'Administrativo',
'pg' => 'Primeiro Grau',
'sg' => 'Segundo Grau',
),
'default_value' => 'ad',
'allow_null' => 0,
'multiple' => 0,
'ui' => 0,
'return_format' => 'array',
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_61035043400f1',
'label' => 'Id Parent',
'name' => 'id_parent',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'lotacao',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
));
endif;
I need to load the api data into the ACF fields, to allow editing the Page Fields in WP Admin.
How do I implement this?
In short I’m trying to use WP Ultimate Importer Pro to export all the posts in my custom post type of Talent, along with all of the associated categories (which include custom taxonomy categories of ‘Location’, ‘Level’, and ‘Specialty’) from one website to another. I want to overwrite the current Talent and Taxonomy values in the 2nd site so that the ID’s of the taxonomy values remain the same. The issue is that it’s not maintaining the same ID for each value, but instead creating duplicate values with new ID values.
The custom post types are using ACF for most of the values including the taxonomy.
More of an explanation…. I have a family of 3 salon sites (custom wordpress theme) that are basically the same backend, just styled differently for each location. We have a custom post type of Talent for each stylist. Many of the ‘talent’ work at multiple locations so we want to maintain the same database of talent, and the same taxonomy, for all three locations. When I make a major update to the talent, I want to be able to export them from one site to the other 2 sites. The issue is when I import them it’s adding new duplicate taxonomy values rather than overwriting what’s there. This will not work because I built a custom filtering engine that uses the ID’s for the Location and Level values.
I have tried importing using both the “New Item” and “Existing Items” options, both with the same results. I have also tried deleting all the custom post (Talent) and all the Taxonomy values, before I import but then the ID’s are just continuing from the last one in the database, since those don’t really get deleted.
So Finally… My three main questions are:
Is there a setting inside WP Ultimate Importer Pro that will allow me to import in the posts and taxonomy values overwriting what’s there… and maintaining the same ID’s as the site exporting from?
Is there any easy way to delete all the DB values for the custom post type and the custom taxonomy values so that when I import them it will keep the same ID’s
Probably the best solution – is there a way to maintain one main database of Talent and taxonomy so that all three sites pull from the same database of talent?
Sorry for the long post but I thought it needed to be explained thoroughly. Thanks in advance for any help or suggestions.
I want to get the post_content from my post object sub field and just simply display the content. Print_r is pulling in the right value, but I can’t get it to echo on the front end. I’ve tried filters, ->post_content, maybe I’m just doing it wrong? I’m still new to ACF.
<?php
$d = get_sub_field('day');
$top = get_sub_field('topic');
$ctxt = get_sub_field('context');
$wtemp =get_sub_field('writing_template');
$ctnt = get_sub_field('content');
$i = get_sub_field('image');
?>
<h1> <?php echo($d) ?> </h1><br>
<?php if( get_sub_field('context') ) { ?>
<p><?php echo($ctxt) ?></p>
<?php } ?>
<?php if( get_sub_field('writing_template') ) { ?>
<p><?php echo($wtemp); ?></p>
<?php } ?>
<?php if( get_sub_field('topic') ) { ?>
<p><strong>Topic:</strong><?php echo($top) ?></p>
<?php } ?>
<?php if( get_sub_field('content') ) { ?>
<p><strong>Content:</strong><?php echo($ctnt) ?></p>
<?php } ?>
<?php if( get_sub_field('image') ) { ?>
<p><strong>Image:</strong> <a>"><?php echo($i) ?></a></p>
<?php } ?>
print_r prints this, I literally just want to display exactly what is in the post_content in a p tag.
Array ( [blog_ad_template_type] => WP_Post Object ( [ID] => 4186 [post_author] => 1 [post_date] => 2021-07-26 04:05:49 [post_date_gmt] => 2021-07-26 04:05:49 [post_content] => Write a social media ad for [wpbb post:terms_list taxonomy=’brand’ html_list=’no’ display=’name’ linked=’no’] for a blog post using the above blurb. ** [post_title] => Blog Ad Template 1 [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => blog-ad-template-1 [to_ping] => [pinged] => [post_modified] => 2021-07-26 04:29:00 [post_modified_gmt] => 2021-07-26 04:29:00 [post_content_filtered] => [post_parent] => 0 [guid] => https://social.hgcreative.co/?post_type=content_template&p=4186 [menu_order] => 0 [post_type] => content_template [post_mime_type] => [comment_count] => 0 [filter] => raw ) [case_study_template_type] => [quote_template_type] => [resource_template_type] => [review_template_type] => [services_template_type] => [story_template_type] => [tip_template_type] => )
Despite what I’ve read and found here and elsewhere, I’m still having trouble figuring out how to get prev/next posts to work with relationship fields on a site and I was hoping for some guidance.
I have a CPT for artworks with custom taxonomy for artists. Then I have another CPT for artists. The artist pages are basically the the page title (artist name) and a relationship field where you add the artist’s artwork from the artworks CPT where you can filter by the custom taxonomy (since there are 50+ artists and 100s of artworks).
Each artwork is its own page as mentioned. When you click on the artwork from an artist page, we want to have the option of going to the next or previous artwork based on the order displayed on the artist page as determined by the order you set from its relationship field. However, the way I have it set now, it obviously just navigates the loop based on the taxonomy and post date as opposed to the order set by the relationship field on the artist page.
<div class="previous-post-link">
<?php previous_post_link('%link', '<div class="prev-link"><i class="fas fa-caret-left"></i></div>', $in_same_term = true, $excluded_terms = '', $taxonomy = 'assignedartist'); ?>
</div>
<div class="next-post-link">
<?php next_post_link('%link', '<div class="next-link"><i class="fas fa-caret-right"></i></div>', $in_same_term = true, $excluded_terms = '', $taxonomy = 'assignedartist'); ?>
</div>
For some reason, I can’t wrap my head around how to query from the single-artist.php (“artist” post type) to the single-artwork.php (“artwork” post type — relationship field, “artworks” ) page and relationship field so I can create Previous and Next links to navigate between artworks. I can manage to pull the page info like title (artist name) but not the relationship field or its order.
I reviewed this post, Next post in relationship field and pages like, ACF Relationship Field Prev/Next Buttons, but their setups are just different enough that I get lost. The latter seems to be limited to a single page, but I have several artist pages. The artwork needs to navigate only the artworks featured on whichever artist page it appears. Any help or direction would be greatly appreciated.
I’m creating a Query, and i need to filter by an ACF date field. In the database the value (in wp_post_meta table) is like this : MM/DD/YYYY
I have few rooms with, as a value in the field date_available_from, this :
And then i do my query like this :
$args[1] = array(
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'cities',
'field' => 'slug',
'terms' => $term_slug,
),
),
'post_type' => 'room',
'meta_query' => array(
'relation' => 'AND',
'date_available_clause' => array(
'key' => 'date_available_from',
'value' => $date_from_format_search,
'compare' => '<=',
),
),
'orderby' => array(
'date_available_clause' => 'ASC',
)
);
Problem 1 : The clause doesn’t works
ex : date_available_from <= 07/19/2021 give me :
date_available_from >= 07/19/2021 give me :
And my sort, is always by month (not by date)
How can i edit my code than let the filter and sort alright ?
I think the problem is that ACF put the format “MM/DD/YYYY” in database. Is there a way to change it ?
Thanks
Hey All,
I am trying to display multiple custom field group for editing from a custom taxonomy location match. I have it working so it will display one or the other but for some reason not both please help.
Rule Types
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices ) {
$choices['Page']['block'] = 'Page Block';
return $choices;
}
Rule Values
add_filter('acf/location/rule_values/block', 'acf_location_rule_values_page_type');
function acf_location_rule_values_page_type( $choices ) {
$terms = get_terms( 'block', array(
'hide_empty' => false,
) );
if( $terms ) {
foreach( $terms as $term ) {
$choices[ $term->term_id ] = $term->name;
}
}
return $choices;
}
Rule Match
add_filter('acf/location/rule_match/block', 'acf_location_rule_match_user', 10, 4);
function acf_location_rule_match_user( $match, $rule, $options, $field_group )
{
$current_user = get_the_terms($_GET['post'], 'block');
$selected_user = $rule['value'];
foreach($current_user as $term){
if($rule['operator'] == "==")
{
$match = ( $term->term_id == $selected_user );
}
if($match == true){ continue; }
}
return $match;
}
If anymore infomation is required please let me know.
I’m trying to filter the taxonomy
list in the image (knipsel) to only make it show the tag that is equal to the current posts_id
. For example: if the post_id
of a post is 10586
then in the list it should only show the tag 10586
.
Project_tag
is an ACF taxonomy field which is placed in the form suggested-items
. I placed the shortcode of the form in a shortcode element (from elementor) to get the list of tags in the image (knipsel). shortcode name is suggested-items
In functions.php I tried the following code to filter the output of the shortcode:
function loop_the_tags() {
$taxonomy = 'project_tag';
// Get the term IDs assigned to post.
$post_tags = get_the_tags( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// Separator between links.
$separator = ', ';
if ( ! empty( $post_tags ) && ! is_wp_error( $post_tags ) ) {
$tag_ids = implode( ',' , $post_terms );
$tags = wp_list_categories( array(
'title_li' => '',
'style' => 'none',
'echo' => false,
'taxonomy' => $taxonomy,
'include' => $tag_ids
) );
$tags = rtrim( trim( str_replace( '<br />', $separator, $tags ) ), $separator );
// Display post categories.
echo $tags;
}
}
In this case it should only return the checkbox with number 10586. (ouput-frontend image)