This method doesn’t work for me, or doesn’t work anymore.
I mean the order and style. The backend dropdown has subcategories differenciated. And O’ve seen that acf uses select2 for the dropdown, that’s what I want to have.
I think I got it, or at least it is working now. I changed into the datepicker field options from 14/09/2915 to d/m/Y (I wrote it manually, I don’t know why selecting the 14/09/2015 option didn’t work).
And now using this code is working fine:
<div class="col-sm-3">
<?php
if(get_field('fecha_del_evento'))
{
$datetime = DateTime::createFromFormat('d/m/Y', get_field('fecha_del_evento'));
$fecha_dia = $datetime->format('d');
$fecha_mes = $datetime->format('M');
}
?>
<div class="eventos row">
<div class="col-xs-3">
<div class="fecha">
<p class="mes"><?php echo $fecha_mes; ?></p>
<p class="dia"><?php echo $fecha_dia; ?></p>
</div>
</div>
<div class="col-xs-9">
<?php the_content (); ?>
</div>
</div>
</div>
Sorry, yes, it is working. Thank you very much for your help.
It was returning an ID, now I’ve changed it to return an object (in the Back-End) and also changed the code, previously I was receiving the following message:
Trying to get property of non-object in… (same as above).
The final code:
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
?>
<?php $i = 0;?>
<?php if($i == 0){ echo "<tr>"; }?>
<td>
<?php
$artista_evento = get_field('artista_del_evento');
foreach ($artista_evento as $av) {
echo get_the_title( $av->ID );
}
?>
</td>
<?php $i++;?>
<td><?php the_field('fecha_del_evento'); ?></td>
<?php $i++;?>
<td><?php the_field('lugar_del_evento'); ?></td>
<?php $i++;?>
<td><?php echo get_the_content(); ?></td>
<?php $i++;?>
<?php if($i == 4){ echo "</tr>"; $i=0;}?>
<?php endwhile; ?>
<?php if($i < 4) echo '</tr>'; ?>
</table>
<?php wp_reset_postdata(); ?>
Hello John,
I recieve this message: Trying to get property of non-object in …/wildlion/wp-content/themes/wildlion/archive-evento.php on line 71 The Faith Keepers en dondesea
Line 71: <td><?php echo get_the_title( $artista_evento->ID ); ?></td>
Hi,
It returns the following message:
jul
Notice: Undefined variable: datetime_object in /home/eurovia1/public_html/wildlion/wp-content/themes/wildlion/single-artista.php on line 209 Fatal error: Call to a member function format() on a non-object in /home/eurovia1/public_html/wildlion/wp-content/themes/wildlion/single-artista.php on line 209
Line 209 -> echo $day = $datetime_object->format(“d”);
Hello @jonathan
Thanks, I did it and got this message:
Fatal error: Uncaught exception ‘Exception’ with message ‘DateTime::__construct():
Failed to parse time string (17/07/2015) at position 0 (1):
Unexpected character’ in /home/eurovia1/public_html/wildlion/wp-content/themes/wildlion/single-artista.php:207
Stack trace: #0 /home/eurovia1/public_html/wildlion/wp-content/themes/wildlion/single-artista.php(207): DateTime->__construct(’17/07/2015′)
#1 /home/eurovia1/public_html/wildlion/wp-includes/template-loader.php(74): include(‘/home/eurovia1/…’)
#2 /home/eurovia1/public_html/wildlion/wp-blog-header.php(16): require_once(‘/home/eurovia1/…’)
#3 /home/eurovia1/public_html/wildlion/index.php(17): require(‘/home/eurovia1/…’)
#4 {main} thrown in /home/eurovia1/public_html/wildlion/wp-content/themes/wildlion/single-artista.php on line 207
So I searched for a solution and came up with this code:
<?php
$datetime_string = get_field('fecha_del_evento');
$datetime = DateTime::createFromFormat('d/m/Y', '$datetime_string');
$month = date_i18n('M', strtotime($datetime));
$day = date_i18n('d', strtotime($datetime));
?>
<?php echo $day; ?>
<?php echo $month; ?>
The code returns the current day, while changing date_i18n to date returns 01-Jan. From here I’m a bit blocked.
You were right, the method that you proposed is the only one (at least that I know) that combines ACF Gallery and Jetpack Carousel. I asked Jetpack support and it is not possible to do what I asked for.
Hello Jonathan,
It doesn’t display nothing after the code, even the footer (which comes after the content). In Addition, I think that it also require a echo $day; or echo $month; to display the values, which doesn’t work either.
Hello John,
Thank for your help, in fact it does work, but it isn’t exactly what I’m trying to achieve. I got this design:
Using this code:
<div class="container">
<div class="row">
<?php
$images = get_field('fotografias_de_artista');
if( $images ): ?>
<div class="col-sm-12"><h2 class="seccion">Fotos</h2></div>
<?php foreach( $images as $image ): ?>
<div class="col-sm-3">
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['sizes']['large']; ?>" class="img-responsive img-disco" alt="<?php echo $image['alt']; ?>" />
</a>
<p><?php echo $image['caption']; ?></p>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div><!-- #row -->
</div><!-- #container -->
What I want is to have the Jetpack carousel for those pictures, but when I try using the code above (your post) it displays a mosaic gallery which I don’t know how to customize.
Thank for your help John, but I am not a coder and I’m lost. Do you know where I can start to understand that code?
I had thought the same, but I’m worried that doing it an existing one would be deleted.
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.