Skip Navigation

[Résolu] How to show futures dates – each on one line?

This support ticket is created Il y a 3 années et 2 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par fred-r.M Il y a 3 années et 2 mois.

Assisté par: Waqar.

Auteur
Publications
#1990225

Tell us what you are trying to do? I have a custom field as typ of date and multiple instances are able to use.

Now I like to show futured dates - from the current dates on - each date on one line...

Is there any documentation that you are following?

Is there a similar example that we can see?

lien caché - under "TourDates"

Right now it just shows me: 18. January 2021, 15. January 2021, 17. February 2021, 25. February 2021

My code is like this - I just should compare the current date with all the dates - and showing only those are in the future.

function get_featured_dates() {

global $post;
$str = '';
$tourdates = get_post_meta($post->ID, 'wpcf-start-tour-date', false);
$alltourdates = count($tourdates);
$mycounter = 0;
while ($mycounter < $alltourdates)
{
$myresults = date( 'd. F Y', $tourdates[$mycounter]);
$mycounter++;
/*$str .= $mycounter;*/
$str .= $myresults.'<br>';
}
return $str;
}
add_shortcode( 'show_featured_dates', 'get_featured_dates' );

What is the link to your site?

lien caché

#1990393

Waqar
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

To make sure your shortcode returns only the future dates from the custom field, you can update it to:


function get_featured_dates() {

global $post;
$str = '';
$tourdates = get_post_meta($post->ID, 'wpcf-start-tour-date', false);
$alltourdates = count($tourdates);
$today = strtotime('today midnight');
$mycounter = 0;
while ($mycounter < $alltourdates)
{
	if($today < $tourdates[$mycounter]) {
		$myresults = date( 'd. F Y', $tourdates[$mycounter]);
		$str .= $myresults.'<br>';
	}
$mycounter++;

}
return $str;
}
add_shortcode( 'show_featured_dates', 'get_featured_dates' );

I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

#1992031

My issue is resolved now. Thank you!

Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance