What do you mean by
I have built some “cards”
My first suggestion would be to add a link field to the field group you set up to add the images and other data.
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/
This one worked better for me, but you have a typo in the js.
Your using double quotes instead of the backtick for the image url.
You’re a lifesaver tysm!
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.
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'
}
)
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?
I’m going to make a guess here that people with this issue are using guberbug gutenberg. No one included this information, so I am assuming.
This is a known issue using the wp block editor. This has been an issue with the new editor for quite some time. There are plenty of topics in this forum about this. I don’t see it being corrected any time soon.
If you select the category and update the post and then reload the page the correct custom fields should appear.
My apologies.
I checked my codes.
There is a closing quote after ‘posts_per_page’.
I think I mistyped it in the message box.
And yes, the slug is “featured”.
Please see the screenshot below.
Thank you.
Did you copy the code exactly? Your original code has a typo in it, missing closing single quote around posts_per_page
'posts_per_page => 10,
Are you sure the category slug is “featured”
I just did a test, correcting the typo and it is returning the correct posts for me.
Hi. Did anybody find a way to do this with the new JavaScript API? For some reason I cannot find the element that is sortable. I tried all of the below methods. I tried other things too, but can’t get working
jQuery( document ).ready( function( $ ) {
if ( typeof acf !== 'undefined' ) {
const field = acf.getField('field_62fb6d4aa3dce');
// field.sortable('disable');
// field.$el.sortable('disable');
// field.$el[0].sortable('disable');
}
});
Any ideas? 🙂
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:
See this: https://support.advancedcustomfields.com/forums/topic/accept-only-unique-values/#post-45359
Hi John,
Thanks for your reply.
I am using field keys for the update, and they update the database with the correct values, but I can’t get the values to link to the custom post type and show in Admin.
Here’s a short version of what I’ve been doing. The whole script duplicates a number of pages and should add their respective field values.
$new_page_id = wp_insert_post([
'post_title' => $new_title,
'post_name' => $new_slug,
'post_content' => $original_page->post_content,
'post_status' => 'publish',
'post_type' => 'page',
'post_parent' => $parent_id,
]);
if ($new_page_id) {
update_acf_field("field_652e5e0552a46", true, $new_page_id, "Is Duplicate");
update_acf_field("field_652e5e2e52a47", $original_page_id, $new_page_id, "Page Id");
}
function update_acf_field($field_key, $value, $new_page_id, $description)
{
$updated = update_field($field_key, $value, $new_page_id);
error_log('-- SET ' . $value. ' - Updated: ' . ($updated ? "true" : "false"));
}
I’m not sure how to proceed, or whether my approach is valid.
Any further help or guidance would be greatly appreciated.
Thank you!
Paul
If you’re looking for assistance with a pre-populated Advanced Custom Fields (ACF) repeater in an inner block template, consider contacting skilled developers or seeking online tutorials offering step-by-step guidance. Trolling forums or communities dedicated to WordPress products could also provide valuable insights. Remember, industry and thorough research often produce fruitful results. For additional help with your specific ACF needs, technical platforms offering technical support might be helpful. Lastly, if you require assistance with academic tasks, consider seeking the Best Assignment Writing Help UK to ensure top-notch quality and timely submissions.
This is a question for elementor and will likely need an add on for elementor that allows conditional display based on the value of a custom field. It is not something that can be done by ACF.
You cannot use shortcodes as an attribute of an element. This is a WP limitation/restriction.
You will need to build your own shortcode that outputs all of the HTML to include ACF fields as attributes.
Starting with version 4.2.3, similar limitations were placed on use of shortcodes inside HTML. For example, this shortcode will not work correctly because it is nested inside a scripting attribute:
<a onclick="[tag]">
Not sure if anyone is still looking for a quick fix, just use the “Icon List” element to pull the ACF field for the title and link and remove the icon if you don’t want it to show.
Downloading multiple files at one time is not something that is easy to accomplish and is well beyond ACF or limited to ACF. I would suggest that you do a web search for “download mulitple images on button click” [search results]. This is going to require putting the images into a .zip file or custom JavaScript or potentially both.
This would require creating custom queries and custom templates for Elementor. You will need to contact elementor, you will probably need elementor pro or some other plugin that allows you to create custom queries and post loops for elementor. This is not something you’ll find help with on this forum.
The only thing that I can do it point you do how to do queries on posts by an ACF date field. This topic has been covered many times on this forum.
[FORUM SEARCH RESULTS]
I have created a code to auto send booking emails after a booking status is updated. Depending on the booking status, a certain e-mail text is called. This function works perfectly so feel free to use it 😉
// Send notification emails to guests
function yl_send_booking_email_after_status_update($post_id) {
// Get submitted values.
$values = $_POST[‘acf’];
// Check if a specific value was updated.
if ( isset($_POST[‘acf’][‘field_5fbcef66c1d3f’]) ) {
$send_email = $_POST[‘acf’][‘field_5fbcef66c1dce’];
$booking_status = $_POST[‘acf’][‘field_5fbcef66c1d3f’];
$to = $_POST[‘acf’][‘field_5fbcef66c18b8’];
if ( $send_email == ‘yes’ && $booking_status != ‘gesloten’ ) {
if ( $booking_status == ‘bevestigd’ ) {
$subject = get_field(‘booking_email_subject_confirmed’, ‘booking_settings’);
$message = get_field(‘booking_email_message_confirmed’, ‘booking_settings’);
} elseif ( $booking_status == ‘gewijzigd’ ) {
$subject = get_field(‘booking_email_subject_changed’, ‘booking_settings’);
$message = get_field(‘booking_email_message_changed’, ‘booking_settings’);
} elseif ( $booking_status == ‘geannuleerd’ ) {
$subject = get_field(‘booking_email_subject_canceled_by_guest’, ‘booking_settings’);
$message = get_field(‘booking_email_message_canceled_by_guest’, ‘booking_settings’);
} elseif ( $booking_status == ‘door ons geannuleerd’ ) {
$subject = get_field(‘booking_email_subject_canceled_by_us’, ‘booking_settings’);
$message = get_field(‘booking_email_message_canceled_by_us’, ‘booking_settings’);
}
$headers = array
(
‘From: ‘ . get_bloginfo(‘name’) . ‘ <‘ . get_bloginfo(‘admin_email’) . ‘>’,
‘X-Mailer: PHP/’ . phpversion(),
‘MIME-Version: 1.0’,
‘Content-type: text/html; charset=iso-8859-1’
);
$headers = implode( “\r\n” , $headers );
wp_mail( $to, $subject, $message, $headers );
}
}
}
add_action(‘acf/save_post’, ‘yl_send_booking_email_after_status_update’, 5);
Now I want to chanllange myself a bit further. I want to auto send (via cron job) a ‘Review request’ email ‘X hours’ after the booking date/time. But I’m stuck for a while now.
Emails do get send but only with pre text. The actuall content of the booking (name, date, time, etc) is left blank.
When I use $post_id
in the function, no emails are being send. I hope I made myself a bit clear.
Here’s what I have:
// Send review emails to guests
function yl_send_review_email_function($post_id) {
// Get submitted values.
$values = $_POST[‘acf’];
$send_email = $_POST[‘acf’][‘field_5fbcef66c1dce’];
$booking_status = $_POST[‘acf’][‘field_5fbcef66c1d3f’];
$review_delay = get_field(‘booking_settings_review_delay’, ‘booking_settings’);
$to = ‘[email protected]’;
$subject = get_field(‘booking_email_subject_review’, ‘booking_settings’);
$message = get_field(‘booking_email_message_review’, ‘booking_settings’) . ‘<br /><br />’ . $send_email . ‘<br /><br />’ . $booking_status . ‘ dit no ‘ . $review_delay;
$headers = array
(
‘From: ‘ . get_bloginfo(‘name’) . ‘ <‘ . get_bloginfo(‘admin_email’) . ‘>’,
‘X-Mailer: PHP/’ . phpversion(),
‘MIME-Version: 1.0’,
‘Content-type: text/html; charset=iso-8859-1’
);
$headers = implode( “\r\n” , $headers );
wp_mail( $to, $subject, $message, $headers );
$status = ‘gesloten’;
update_field( ‘booking_status’, $status );
}
add_action(‘acf/save_post’, ‘yl_send_review_email_function’, 5);
// Time schedule for Cron Job Event
function yl_cron_schedules($schedules){
if(!isset($schedules[“1min”])){
$schedules[“1min”] = array(
‘interval’ => 1*60,
‘display’ => __(‘Once every minute’)
);
}
if(!isset($schedules[“5min”])){
$schedules[“5min”] = array(
‘interval’ => 5*60,
‘display’ => __(‘Once every 5 minutes’)
);
}
if(!isset($schedules[“30min”])){
$schedules[“30min”] = array(
‘interval’ => 30*60,
‘display’ => __(‘Once every 30 minutes’)
);
}
return $schedules;
}
add_filter(‘cron_schedules’,’yl_cron_schedules’);
// Schedule Cron Job Event
if (!wp_next_scheduled(‘yl_booking_review_mailer’)) {
//You can now use ‘5min’, ’20min’ or any of the default here
wp_schedule_event( time(), ‘1min’, ‘yl_booking_review_mailer’ );
}
add_action( ‘yl_booking_review_mailer’, ‘yl_send_review_email_function’ );
PS. I left the needed IF STATEMENTS out to be sure that’s nog stopping emails going out.
@nicmare I apologize. Completely my mistake on the formatting.
add_filter( 'render_block_core/post-title', function( $block_content, $block ) {
if(!empty($block["attrs"]["className"]) && $block["attrs"]["className"] == "duration") {
return sprintf("<div style='margin-bottom:%s'><strong>%s</strong></div>%s","10px",get_field("clip_duration"),$block_content);
} else if (!empty($block["attrs"]["className"]) && $block["attrs"]["className"] == "readAuthor") {
$author = get_field('author');
foreach( $author as $theAuthor ) {
$authorName = get_the_title( $theAuthor->ID );
}
return sprintf("<h4>Read / %s</h4>",$authorName,$block_content);
} else {
return $block_content;
}
}, 10, 2 );
what do you think what i am? A machine? I can not read your comment / code. So i can not help you. But placing custom content before/after something is just like changing the order in the code. code for outputting the acf field after the title:
add_filter( 'render_block_core/post-title', function( $block_content, $block ) {
if(!empty($block["attrs"]["className"]) && $block["attrs"]["className"] != "company") return $block_content;
return sprintf("%s<div style='margin-top:%s'><strong>%s</strong></div>",$block_content,"10px",get_field("company"));
}, 10, 2 );
@nicmare This worked great to get the contents of a text field output right after a title. But now I want to have multiple injections that show up in different places.
I modified your code to combine the items. It throws no errors, but when I used your code to output one item, then the other, separately, they worked. After combining them, it no longer works. I wonder if you or anyone else could help.
add_filter( 'render_block_core/post-title', function( $block_content, $block ) {
if(!empty($block["attrs"]["className"]) && $block["attrs"]["className"] == "duration") {
return sprintf("<div style='margin-bottom:%s'><strong>%s</strong></div>%s","10px",get_field("clip_duration"),$block_content);
} else if (!empty($block["attrs"]["className"]) && $block["attrs"]["className"] == "readAuthor") {
$author = get_field('author');
foreach( $author as $theAuthor ) {
$authorName = get_the_title( $theAuthor->ID );
}
return sprintf("<h4>Read / %s</h4>",$authorName,$block_content);
} else {
return $block_content;
}
}, 10, 2 );
I tried that as well, and have the same result
$args = array('orderby' => 'display_name',);
$users = get_users($args);
foreach($users as $user){
$userID = 'user_'.$user->ID ;
echo '<li>';
echo '<b style="font-size:14px;">' . $user->data->display_name . ' x' . $user->emp_office_ext . '</b><br/>';
echo '<em style="font-size:12px;white-space: nowrap; ">' . get_field('position',$userID) . '</em>';
if (!empty(the_field('manager',$userID))){
$manager = get_field('manager');
echo $manager['display_name'];
}
echo '</li>';
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.