yoast-acf-analysis
yoast-acf-analysis copied to clipboard
Wrong date format for ACF date picker field
Moved from Jira: https://yoast.atlassian.net/browse/IM-1818 Reporter: @amboutwe
Description ACF includes a date picker field type. Yoast SEO automatically adds custom fields to the variable list. When adding the date picker ACF field to the title or description, the output uses the unformatted date instead of the format selected in ACF options.
This happens with or without the ACF + Yoast glue plugin.
Video: https://watch.screencastify.com/v/344zczyb1179n3of5ZDe
To Reproduce
Steps To Reproduce
Starting with a vanilla installation:
- Install and activate Advanced Custom Fields
- Create a custom field (steps below)
- Go to Admin > Posts > Add new
- Create a new post 'Yoast date test' and pick a date in the ACF metabox.
- Add some content and publish the post
- Go to Admin > Appearance > Theme File Editor
- Edit 'header.php' and add the lines below to the end of the file
- Click 'Update File'
- View post created with the above steps - See formatted date and unformatted date.
- Install and activate Yoast SEO (free)
- Edit post created with the above steps
- Add the 'Date (custom field)' variable at the start of the SEO title
- View post - See title has the unformatted date
- Install and activate ACF Content Analysis for Yoast SEO
- View post - See title still has the unformatted date
Create custom field
- Go to Admin > Custom fields > Add new
- Enter 'Yoast date test' in the title
- Click 'Add Field'
- Field Label = Date
- Field Name = date
- Field Type = Date picker
- Display Format = F j, Y
- Return Format = F j, Y
- Click 'Publish'
Add snippet to header.php
<?php
$pluginList = get_option( 'active_plugins' );
$plugin = 'advanced-custom-fields/acf.php';
if ( in_array( $plugin , $pluginList ) ) { ?>
<p style="margin-left: 3em">Date (no formatting): <?php the_field('date', false, false); ?> <br />Date (formatting): <?php the_field('date'); ?></p>
<?php }
?>
Expected Results
Date to use the display format from ACF
Actual Results
The unformatted date is shown
Impact ACF users that want to show the ACF date field in the title or description.
WordPress version : 5.9.2
Please inform the customer of conversation # 961892 when this conversation has been closed.
Please inform the customer of conversation # 881923 when this conversation has been closed.
i have the same problem, can someone help me?
Thanks in advance!
Hi @backupsideag
This issue still needs to be fixed, and it's on our development team's radar. Our product team will assess the severity of the issue and assign a priority level to the report. Our developers work on the highest priority issues first. We cannot give you an estimate of when they'll start working on the issue.