Hey Trishah,
You just need to use a conditional on your loop, something like that:
$date = date( "U" , strtotime( get_sub_field('file_date')));
$new = date("U") - 1538943104;
if($date < $new) :
[....]
endif;
Hey man!
If you want to every post on page have it’s own form, you can do something like this in your acf_form() function:
acf_form(array(
'form_id' = 'form_' . get_the_ID(),
'post_id' = get_the_ID()
[...]
));
Assuming that you are going to place that inside the loop like that
while(have_posts()): the_post()
P.s.: Sorry about my english
Hey man,
Inside the loop you don’t need to pass the post id argument. Try if just $xxx = get_fields();
And remeber, ” get_fields() ” will only return fields that have value on the post
Hey Vancha,
You just need to pass a filter on your footer file, something like:
if(get_field("field_key_xxxx"){
echo "[xxxxxxxxx]";
}
I recommend you to use the “true/false” field type for this
Hey @phil-owen ,
Just to be sure, why don’t you use the default acf title on acf_form function? Something like that:
acf_form(array(
"post_title" => true,
[....]
))
P.s.: Sorry about my english
Hey man, did you tried acf_form() to load your fields?
Hello Malachi,
You will need more then just ACF to your filter work.
I recommend you to use ACF map to save the location of your contractors and then use Google’s API “Distance Matrix” to filter the results on your query.
P.s.: Sorry about my english
You can’t use “get_current_user_id()” inside the loop, sorry about that, try this instead:
foreach ($org_users as $user) {
$user_id = $user->user_id
[.....]
<?php
function vv_custom_cat_layout( $options ) {
$terms = get_terms( array(
'taxonomy' => 'product_cat',
'hide_empty' => true,
'meta_key' => 'series_one_work',
'meta_value' => '1'
) );
$AcfFilter = array();
foreach($terms as $term){
array_push($AcfFilter, $term->name); # i'm never sure if is term_name or just name, sorry
}
if ( is_product_category( $AcfFilter ) )$options['columns'] = 1;
return $options;
}
add_filter( 'option_generate_woocommerce_settings','vv_custom_cat_layout' );
Try this
function vv_custom_cat_layout( $options ) {
$terms = get_terms( array(
'taxonomy' => 'post_tag',
'hide_empty' => true,
'meta_key' => 'name_of_field',
'meta_value' => 'the_desired_value'
) );
foreach($terms as $term){
$options['columns'] = 1;
}
return $options;
}
add_filter( 'option_generate_woocommerce_settings','vv_custom_cat_layout' );
*not tested
Remember to save your permalink settings after use this function
Awesome!
I guess this could work (not tested)
Change the ” {query_of_post_by_slug} ” for get_the_ID($post);
function vv_cpt_acf_permalink($post_link, $post = 0)
{
if ($post->post_type === 'fahrten') {
$post_id = get_the_ID($post);
$field_value = get_field("fahrt_id",$post_id);
return $post_link . '/?tour_id='.$field_value);
} else {
return $post_link;
}
}
add_filter('post_type_link', 'vv_cpt_acf_permalink', 1, 3);
Hey man,
Can you send the error message?
Hey man,
As far as I know, you can do this with the “fields” paramenter on acf_form(), something like this:
acf_form(array(
'fields' => array('key_01','key_02');
))
Hey man!
Sorry if I did not understand your question correctly.
But the “add_action” you are using in this code is only for the posts query (like filtering CPTS when they appear on your website frontend).
To update permalinks you need some +/- like this:
function vv_cpt_acf_permalink($post_link, $post = 0)
{
if ($post->post_type === 'fahrten') {
$post_id = {query_of_post_by_slug};
$field_value = get_field("fahrt_id",$post_id);
return $post_link . '/?tour_id='.$field_value);
} else {
return $post_link;
}
}
add_filter('post_type_link', 'vv_cpt_acf_permalink', 1, 3);
Hey man!
You must use something like that:
$user_id = get_current_user_id();
get_field("key","user_".$user_id);
the_field("key","user_".$user_id);
Hey Raul,
You can loop categories using a “meta_key” / “meta_value” filter to update only categories with the value TRUE in “series_one_work”
P.s.: sorry about my english
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.