Skip Navigation

[Gelöst] How to show futures dates – each on one line?

This support ticket is created vor 3 Jahren, 8 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von fred-r.M vor 3 Jahren, 8 Monaten.

Assistiert von: Waqar.

Author
Artikel
#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?

versteckter Link - 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?

versteckter Link

#1990393

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!