Actually I want to trim or limit the content, as I said that I want to show some of the checkboxes not all.
john this is for comma implode, but how I can trim the checkboxes with comma implode.
How I can do trim with this?
$values = get_field('job_location');
if( count($values)){
foreach($values as $k=>$value){
if($k) echo ', ';
echo $value;
}
}
Ok I fixed it, thanks.
$currentdate = new DateTime();
$date = get_field('last_date', false, false);
$date = new DateTime($date);
if ($currentdate > $date) {
echo '(Job Expire)';
} else {
echo get_field( 'last_date' );
}
Actually, I am using ACF and I create a date field with the name of (LAST DATE). So I just want to show a specific text after or replace the field.
For Example, I added the last date 15 Dec 2019 and it’s showing me on my site. When 15 Dec 2019 gone then it will show like this.
Replace The date: Job Expire
Hello, any help with this???
@huwrowlands I try your code but it’s not working for me. Can you make it easier than when the date has gone it shows closed text, instead of creating a new field for OPEN & CLOSE? But I try with Radio fields also and it’s not working.
I test on my site and its working fine for me. Please check your other plugins or any browser extensions.
Try to use ACF Better Search plugin.
You can do that..
<?php if( get_field('field_name') ): ?>
<p>My field value: <?php the_field('field_name'); ?></p>
<?php endif; ?>
Here is the official link
https://www.advancedcustomfields.com/resources/hiding-empty-fields/
Should I copy paste that code and change the field only?
Yes I am talking about front end. I am using this code..
<p>Colors: <?php the_field('colors'); ?></p>
This is checkbox, let say I have checked 6 checkboxes and its showing me 6 options in front end..
e.g in front end..
USA, UAE, Canada, Pakistan, England, China,
But I want to trim them to show only 2 options not to trim the words.
e.g
USA, UAE…Not this;
USA, UAE, Canada, Pakistan, Eng…
And currently did not using any tool tip code.
I try to remove some lines and done this but got 2 problems.
1st is no commas and space in between text
2nd is the last field comes 2 times
Screenshot: https://prnt.sc/low0fl
<?php
$field_value = get_field('job_qualification');
$field_object = get_field_object('job_qualification');
$services = $field_object['choices'];
foreach($services as $value => $label){
if (in_array($value, $field_value)) {
$servicesList = "<a target='_blank' href='https://jobsalert.pk/edu/$value'>$label</a>";
}?>
<?php echo str_replace(',', ' , ', $servicesList); ?>
<?php } ?>
I did this on check-boxes and its working but for this I have to update every posts to add link. Why its not make hyperlink on check-boxes which I posted in posts.
<a target="_blank" href="https://mysite.com//masters">Masters</a> : Masters
<a target="_blank" href="https://mysite.com/graduation">Graduation</a> : Graduation
<a target="_blank" href="https://jobsalert.pk/edu/intermediate">Intermediate</a> : IntermediateD
Ok, Can we make this kind of thing with CHECKBOXES?
I want auto system as like wordpress calendar. When we click on date then we got a page where we can see the posts. So we dont have to create all pages/post for dates. So is there any code for this, what ever we give text, it will create a auto link.
Is there any code like wordpress have date system, links created automatically. I want auto system, means I dont want to add links manually.
This thing will be manually, cant be automated? Means city will be clickable and when we click, it will take to you archive style page?
Which you gave me, for better thing is CHECKBOX
I fixed it..
<?php if ( get_field( 'field_name' ) ): ?>
FIELD CODE....
<?php else: // field_name returned false ?>
OTHER CONTENT IF FIELD IS EMPTY
<?php endif; // end of if field_name logic ?>
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.