-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
Description
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