Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong date format for ACF date picker field #330

Open
josevarghese opened this issue Feb 6, 2023 · 4 comments
Open

Wrong date format for ACF date picker field #330

josevarghese opened this issue Feb 6, 2023 · 4 comments
Labels

Comments

@josevarghese
Copy link

josevarghese commented Feb 6, 2023

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:

  1. Install and activate Advanced Custom Fields
  2. Create a custom field (steps below)
  3. Go to Admin > Posts > Add new
  4. Create a new post 'Yoast date test' and pick a date in the ACF metabox.
  5. Add some content and publish the post
  6. Go to Admin > Appearance > Theme File Editor
  7. Edit 'header.php' and add the lines below to the end of the file
  8. Click 'Update File'
  9. View post created with the above steps - See formatted date and unformatted date.
  10. Install and activate Yoast SEO (free)
  11. Edit post created with the above steps
  12. Add the 'Date (custom field)' variable at the start of the SEO title
  13. View post - See title has the unformatted date
  14. Install and activate ACF Content Analysis for Yoast SEO
  15. View post - See title still has the unformatted date

Create custom field

  1. Go to Admin > Custom fields > Add new
  2. Enter 'Yoast date test' in the title
  3. Click 'Add Field'
  4. Field Label = Date
  5. Field Name = date
  6. Field Type = Date picker
  7. Display Format = F j, Y
  8. Return Format = F j, Y
  9. 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

@josevarghese
Copy link
Author

Please inform the customer of conversation # 961892 when this conversation has been closed.

@josevarghese
Copy link
Author

Please inform the customer of conversation # 881923 when this conversation has been closed.

@backupsideag
Copy link

i have the same problem, can someone help me?

Thanks in advance!

@josevarghese josevarghese added the IM label Feb 5, 2024
@josevarghese
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants