Do you need to declare the type?
'time_clause' => array(
'key' => 'from_time',
'compare' => '=',
'type' => 'time',
),
What does the time field return? Is it HH:MM:SS?
How are you storing the values? I’ve previously found storing a date or time in a text field has caused some issues. Are they dedicated date/time fields?
Hi @ajaykasam1
You can just output the values in a table format:
<?php
$firstname = get_field('firstname');
$surname = get_field('surname');
$year = get_field('year');
$title = get_field('title');
?>
<table class="table">
<thed>
<tr>
<?php if( $firstname ): ?>
<th scope="col">First Name</th>
<?php endif; ?>
<?php if( $surname ): ?>
<th scope="col">Surame</th>
<?php endif; ?>
<?php if( $year ): ?>
<th scope="col">Year</th>
<?php endif; ?>
<?php if( $title ): ?>
<th scope="col">Title</th>
<?php endif; ?>
</tr>
</thed>
<tbody>
<tr>
<?php if( $firstname ): ?>
<th scope="row">First Name</th>
<?php endif; ?>
<?php if( $surname ): ?>
<td>Surame</td>
<?php endif; ?>
<?php if( $year ): ?>
<td>Year</td>
<?php endif; ?>
<?php if( $title ): ?>
<td>Title</td>
<?php endif; ?>
</tr>
</tbody>
</table>
Can you not use conditional code like:
$length = get_field('length');
if( $length ):
echo 'Length: '.$length.' cm';
endif;
Repeat for each field
In which case, you need to target just that code with CSS.
Something like:
.cat-extra-dis ul {
list-style: circle;
}
And remove the other CSS change you made. See if that works
Hmm, nothing wrong with the code.
What is the field type? I assume a WYSIWYG field?
Do you have any CSS overriding the styling?
If you inspect the list with the browser tools, does it output as HTML UL and LI?
You will need to share the code that outputs/displays your extra field you’ve created.
I’m not familiar with Elementor however, I believe you need the acf add-on.
Do you have that in place? Otherwise, I think it’s limited on what you can edit or doesn’t allow any editing.
this article may show you a bit more on what can be editable
Please can you share your code? Is this on a single post or within a loop?
Assuming it’s set to array, your code should look like:
<?php
$image = get_field('review_icon');
if( !empty( $image ) ): ?>
<img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
<?php endif; ?>
Please can you share your code? It’s possible you may be escaping the HTML so may remove the formatting
Hi @germanpc
That looks like a Gravity Forms function, is that correct? If so, does the form get triggered multiple times?
Can you add a simple debug line to the function and see if that gets repeated? I sometimes add a snippet to send myself an email. I include the data fields to ensure they contain the info, if the function then fired twice, you’d get two emails, so would then know to check GF rather than ACF
Checking the docs for that plugin, you can see:
Can admin add custom fields to the frontend submission form for the WP User?
No, Custom fields are not supported with this user-generated content plugin.
If you want something similar, you can either:
1) Do a custom form using the ACF plugin which can submit posts OR
2) Look at something like Gravity Forms. You can then submit posts but also link into custom fields (it even has an add-on to map the fields)
HI @yett
I think you would need to add the field to the order not the product.
You then need to add the code to the emails:
/**
* Add a custom field (in an order) to the emails
*/
add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 );
function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields['Begindatum'] = array(
'label' => __( 'Begin Datum' ),
'value' => get_post_meta( $order->id, 'Begindatum', true ),
);
return $fields;
}
If you’re using a plugin for the invoices, you may need to check if they have any hooks
Looking at the docs
You simply need to loop through your checkbox field:
<?php
$colors = get_field('colors');
if( $colors ): ?>
<ul>
<?php foreach( $colors as $color ): ?>
<li><?php echo $color; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Just change colors to your field name
Hi @hcmendez
I’d be inclined to use a repeater field for the ingredients list. I’d have 2 fields:
1. The ingredient
2. A post object which is then set to use products
The code would then loop through the repeater fields, listing the ingredients but you can then create your links using the post object.
If you name your acf fields the same as the woocommerce ones, it might work.
It may be worth checking in the database the exact name, as it might be something like _price.
Hi @shoxt3r
My guess would be the main films template page you still have:
<div id="ajax_filter_films">
<?php
$args = array(
'post_type' => 'film',
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
if( $query->have_posts() ) :
while( $query->have_posts() ): $query->the_post();
?>
<h2><?php the_title(); ?></h2>
<?php
endwhile;
wp_reset_postdata();
else :
echo 'No films found matching your criteria.';
endif;
?>
</div><!-- /ajax_filter_films -->
Which if I view the source code on your link, just shows a list of H2 tags
So you need to replace the bit in the while loop with whatever you need to show.
What if you create a repeater in the theme options.
It has title, description, link etc. But you add another column for post object. This is then a multiselect and allows the user to select which page that row should appear on. I’d set it to return the post ID
Your code then needs a line in your repeater which gets the current page ID and compares it to the row post object IDs. If it matches, show the content.
Would that work?
Please re-read what I asked for and reply
What does $label output?
How have you got the field setup?
What data are you entering?
The new ACF fields won’t save because you’re not triggering the additional form with the ACF fields.
From what I can see you have 2 options:
1) I’m not sure what the enhanced review plugin does, but maybe you can remove it and look to add the functionality another way, therefore, allowing you to add the ACF fields as mentioned above OR
2) You see if the enhanced review plugin has a hook/action on save, therefore, once the review form is triggered, you run a function to get the field data from the ACF fields and use update_field() to insert the data
Unfortunately, update_field doesn’t work for deleting rows out of a repeater.
The delete_row function is also pretty simple!
As far as I know, it’s the only option if you want to delete content from repeaters
For alternating rows, should the row tag not be in the loop and the alternative class be applied to that?
That way, you could also wrap the if( $field[‘value’] ): around the row, so shouldn’t break if a row returns empty.
Removing a row from a repeater is different to update_field.
If you check the docs
You need something like:
// Delete the first row of data.
delete_row('images', 1);
Where 1 is the row number and images if the field name
Just amend the HTML to include the $label in the a tag:
<?php
$field = get_field_object('field_name');
if( $field['choices'] ): ?>
<ul>
<?php foreach( $field['choices'] as $value => $label ): ?>
<li><a href="<?php echo $label; ?>"><?php echo $label; ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
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.