
Hi @clickpanic
I get what you want.. but I don’t get why?
What kind of data do you want to save from each contributor on a post? Or am I misunderstanding you?
I interpret your idea that you want to let different users add different values to a post in the same field (like user specific inputs).

In what way do you mean to get it working on the front end?
The original question is about adding WooCommerce product attributes through ACF fields when creating a produkt.

Hi @brian1037
No worries it will work just fine! you don’t need to use any key as seen in the example code of the documentation.
https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false
However since you input the maps api yourself in the frontend (ACF will not do this for you) you can just use it with your key if you like.

Hi @karks88
Almost..
But I would say there’s no need for you to query all posts and then do the check when you can just query all past posts directly and change their statuses..
if (!wp_next_scheduled('expire_posts')){
wp_schedule_event(time(), 'hourly', 'expire_posts'); // running hourly for testing purposes
}
add_action('expire_posts', 'expire_posts_function');
function expire_posts_function() {
$today = time('Ymd'); // matches the date in DB
$args = array(
'post_type' => array('post'), // array of the post types you want to check
'posts_per_page' => 200 // get all the posts but don't set it t o -1 since its a risk of overloading the server
'category' => 'events',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'event_ending_date',
'value' => $today,
'compare' => '<' // you might have to switch this out for >
)
)
);
$post_query = new WP_Query($args);
if( $posts->have_posts() ){
while( $post_query->have_posts() ){
$post_query->the_post();
wp_transition_post_status('draft', 'publish', $post);
}
wp_reset_postdata();
}
}

Hi @aaronrobb
While it would be possible to hook into acf/save_post and extract the value from the map field into another field (could be a hidden field if you like) I’m not sure how you would go about making sure you ONLY get the city.. It can be any length of string, with or without spaces etc. etc.
When I’ve had situations like this in the past I’ve actually used a custom taxonomy for location as well. It can be just for cities but you can also use a hierachial one and let the user apply country > region > city > part (really as far or not as you want).
The taxonomy makes for much better filtering options as well 🙂

Hi @jpegtobbe
Will notify Elliot of this!

I’m not sure wether you’re asking if you can select when to do specific sorting or IF you can reverse the sorting?
In the example this is used:
array_multisort( $order, SORT_DESC, $value );
so to sort the other way around you could do
array_multisort( $order, SORT_ASC, $value );

First off, what kind of field is show_season?
If it’s a post object field you can’t just use it directly to get the title.
This would be the correct code:
$post_object = get_field('show_season');
$title = get_the_title($post_object->ID);
Secondly. Where is the role located? Is it inside the post selected in show_season? You can never use any *_sub_field() function out of context.. they will always need to be inside a have_rows loop or they wont work.

As a developer that works almost exclusively with WordPress since years back I’ve probably built ~100 sites with WordPress. Most of these have used ACF. I don’t think ACF will ever attempt to create content on the front end automatically and I honestly don’t think it should. It would work against ACFs greatest feature which is flexibility.
However I completely agree that it should be more clear!

Hi @timm
I think what’s happening here is that since WordPress does not load the automatic oembed detection/conversion scripts in frontend you wont see the “transformed” video from pasting an URL.
I’ll assign @elliot to this issue to see if there’s anything that can be done.
He’s rather busy tho so it might take a while to get a response.

Hi @marek-234
Great to hear!
Yes I assumed you had ACF set to image object which your code would’ve worked with 🙂
Best of luck with your coding

Hi @okozarsky
I think your issue is that you don’t know what the page link field does..
It will ONLY return the link (url) to the selected post.
What you really want is a post object field..
Then to get the link you’d do
$post_object = get_field('thepostobjectfield');
$page_link = get_permalink(post_object->ID);
$page_title = get_the_title($post_object->ID);

Hi @debendra
Great to hear!
The code looks solid. I also have a fondness for ACF 😉
Best of luck with your coding

Hi @ericcarroll
Great to hear that everything has resolved for you!
ACF does absolutely nothing automatically for the front end (which is actually just right if you ask me 🙂 ). So while I don’t think it needs that much of an explanation perhaps this confusion can be avoided with just some minor wording tweaks.
instead of just Wrapper attributes we could apply a short text underneath as with many of the labels above.. like Used in admin.
Do you think that’d be enough?

You’re welcome 🙂
If you do end up tweaking the taxonomy field you could post a link to it here.
While Elliot probably wont just include it in ACF it may speed up the process for him to add the same functionality to core.
Have a good one

Cool! Yeah the post object is much easier to manipulate if you only require one..
Since ACF started to use select2 for the dropdowns it’s just as easy to use as the relationship field.. (earlier on I used to utilize relationship field even if I only needed 1 due to the interface).
Best of luck in your project!

No problem!
Feel free to contact us if you need further help with getting started with ACF.
The documentation should be a great help too.

Hey!
So you’re sort of twisting and turning the query around. You start off with terms which you use to query posts which then are used to show terms.
Your code is a bit confusing.. I’ll post a cleaned up version here but first I want to talk about what it does.
So with the current code you fetch ALL terms in the taxonomy systemcontents_category2. You then loop through each term and perform a wp_query which fetches all posts connected to that term.
Then you loop through each post and output the terms name and some information from the post.
Nowhere is $selected being used and I don’t quite get what it is you want to use it for either. You should also be using ACFs API functions like get_field() to fetch the meta values for the post.
If this is not what you need please try to explain further and possibly include a screenshot of your ACF setup.
<?php
$member_group_terms = get_terms('systemcontents_category2');
$selected = get_sub_field('system_contents_posts');
?>
<?php foreach ( $member_group_terms as $member_group_term ) endforeach; ?>
<?php
$args = array(
'post_type' => 'pj_systemcontents2',
'posts_per_page' => 400, //unlikely high
'tax_query' => array(
array(
'taxonomy' => 'systemcontents_category2',
'field' => 'slug',
'terms' => array( $member_group_term->slug ),
'operator' => 'IN'
)
)
);
$member_group_query = new WP_Query($args);
?>
<?php if ( $member_group_query->have_posts() ) : ?>
<h3><?php echo $member_group_term->name; ?></h3>
<?php while ( $member_group_query->have_posts() ) : $member_group_query->the_post(); ?>
<?php echo get_field('document-section'); ?>
<?php echo get_field('document-reference') . ' ' . get_field('document-sub-section'); ?>
<?php endwhile; wp_reset_postdata(); ?>
<?php endif; ?>
<?php endforeach; ?>

No Problem!
Best of luck in your project!

No problem 🙂
The reason I suggested wp_get_object_terms rather than wp_get_post_terms is because the second function is really just a wrapper for the first which is meant to be used with regular posts. I’ve experienced some cases where such a wrapper function would not work for custom post types etc. and as thus always try to avoid using them out of context.
Best of luck in your project!

Hi @et3rnal
Nope that looks about right to me 🙂

The scheduling of a post works the same as any wp cron so it would not make any difference if no one visits your site. I think the right way to go is to create your own cron job as you initially thought.
To make wp cron more reliable is actually pretty simple if you have access to cron on your server/hosting.
https://tommcfarlin.com/wordpress-cron-jobs/
I don’t know what “Advanced Custom Fields Contact Forms” is but I assume it’s a third party plugin. I will assume it creates a CPT which all the submissions are saved to as posts.
I would create a cron job that triggers a function. In the function you query the submissions for date values where the date is in two days from today. Then in the loop you find the users email and send out an email using wp_mail. It’s all fairly simple if you’re familiar with PHP 🙂
Here’s how to get a date two days from now:
$date = date('Ymd', strtotime('+2 days'));
and a query
$upcoming_query = new WP_Query(array(
'post_type' => 'submissions' //whatever it is
'meta_query' => array(
'key' => 'acffield',
'value' => $date,
'compare' => '='
),
'posts_per_page' => 100,
'no_found_rows' => true,
'update_post_term_cache' => false
));

Hi @virtualexpo
You’ve not posted enough code to understand what’s going on here..
There’s no reference to $postId other than where you use it in your shortcode.
You could post the entirety of your code on a service like http://pastie.org/ so it can be better viewed 🙂

Hi @musenuovo
This is the correct syntax for fetching from an options page:
get_field('image', 'options');
You missed the plural form of option 🙂

Q1:
An image is really a post type “attachment” as I’m sure you know. The ID in the $image is thus the attachments ID. So you should be able to fetch the term like:
//will return an array of term objects.
$terms = wp_get_object_terms($image['ID'], 'image_gallery');
Q2:
ACF uses the same image modals as WordPress core so this is really not an ACF thing. You’ve registered your custom taxonomy and now you need to add it to the modal. I don’t have any code for this but I’m sure you can find some by googling 🙂
There’s also plugins out there and this is one of the most tested: https://wordpress.org/plugins/enhanced-media-library/
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.