$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>php - Wordpress Post undefined error with Post Date (New to Wordpres Dev)|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - Wordpress Post undefined error with Post Date (New to Wordpres Dev)

matteradmin9PV0评论

I'm getting an error on a new page with the current Date posted

Notice : Undefined index: ama_text_field_01_2019 on line 57 /

When I checked the error line it says

$options = get_option( 'ama_settings' ); $field = 'ama_text_field_' . get_the_date("m") . '_' . get_the_date("Y"); 57: $options = get_option( 'ama_settings' ); $data = str_replace(' ', '', trim($options[$field]));

To troubleshoot, I changed the Date posted to 2018 instead of 2019. That fixed the error. But going forward this isn't a solution.

Any areas I can look into to fix?

I'm getting an error on a new page with the current Date posted

Notice : Undefined index: ama_text_field_01_2019 on line 57 http://magazine.americanmotorcyclist/6607/quest-completed/

When I checked the error line it says

$options = get_option( 'ama_settings' ); $field = 'ama_text_field_' . get_the_date("m") . '_' . get_the_date("Y"); 57: $options = get_option( 'ama_settings' ); $data = str_replace(' ', '', trim($options[$field]));

To troubleshoot, I changed the Date posted to 2018 instead of 2019. That fixed the error. But going forward this isn't a solution.

Any areas I can look into to fix?

Share Improve this question asked Jan 16, 2019 at 18:50 JthomasJthomas 112 bronze badges 2
  • This code looks plugin or theme specific so it's hard to say how to fix this as it's not clear what you're trying to do. What is the desired result of what you're trying to do? – Swen Commented Jan 16, 2019 at 18:57
  • I figured it was a theme issue. Basically, a new post displays this error when the date is set any time for 2019. 2018 - No error. – Jthomas Commented Jan 16, 2019 at 19:04
Add a comment  | 

1 Answer 1

Reset to default 0

To just get the post date, you can replace that entire section of code with just the get_the_date() function.

To display the article's date, use this code:

<?php echo get_the_date(); ?>

Check out the date format options on the codex page linked above to customize it to your liking, if necessary.

Post a comment

comment list (0)

  1. No comments so far