Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何更正WordPress Genesis网站页脚中显示的不正确年份?_Php_Wordpress_Date_Genesis - Fatal编程技术网

Php 如何更正WordPress Genesis网站页脚中显示的不正确年份?

Php 如何更正WordPress Genesis网站页脚中显示的不正确年份?,php,wordpress,date,genesis,Php,Wordpress,Date,Genesis,这可能是一个非常具体的问题&有点新的问题,但PHP是我比较薄弱的领域之一——我想我知道是什么导致了这个问题,我只是不确定用什么来取代它。这个问题看起来像get_The_date()显示的是帖子(页面等)的创建日期,而不是当前日期。我一直在仔细阅读关于日期()的文档,但我还没有弄清楚应该用什么来替换获取日期('Y')&我想这部分是因为我们在函数中使用了速记,我担心这花了我几个小时的时间 以下是我们目前正在使用的内容: // Custom Footer Credits add_filter('gen

这可能是一个非常具体的问题&有点新的问题,但PHP是我比较薄弱的领域之一——我想我知道是什么导致了这个问题,我只是不确定用什么来取代它。这个问题看起来像get_The_date()显示的是帖子(页面等)的创建日期,而不是当前日期。我一直在仔细阅读关于日期()的文档,但我还没有弄清楚应该用什么来替换获取日期('Y')&我想这部分是因为我们在函数中使用了速记,我担心这花了我几个小时的时间

以下是我们目前正在使用的内容:

// Custom Footer Credits
add_filter('genesis_footer_creds_text', 'custom_footer_creds_filter');
function custom_footer_creds_filter( $editthecredit ) {
  $editthecredit = 'Copyright © ';
  $editthecredit .= get_the_date( 'Y' );
  $editthecredit .= ' ';
  $editthecredit .= get_bloginfo( 'name' );
  return $editthecredit ;
}
// End Footer Credits
问题是get_The_date('Y')返回页面创建的日期。我见过人们使用echo获取日期('Y')的地方,但这破坏了网站


起初我认为这是因为我们可能需要取消注册默认的Genesis页脚,所以我在这里使用了Brian Gardner的一些建议(),但没有任何区别。

WordPress'
函数的作用是显示当前循环项(Post、Page等)的日期

如果您想要今天的日期,请使用。例如,以下内容打印出今天的年份:

echo date('Y');
特别针对您的情况:

$editthecredit .= date('Y');

因此,您希望回显当前年份,
date('Y')
?…正确-使用如图所示的代码,它只显示当前正在查看的页面的创建日期。另外,在混音中添加“echo”会带来wsods,就是这样!血腥的简单&正是我们所需要的-谢谢DACrosby!我将把这个标记为已接受的答案。