Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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中将较旧的帖子移动到另一个类别_Php_Wordpress_Archive_Wp List Categories - Fatal编程技术网

Php 如何在wordpress中将较旧的帖子移动到另一个类别

Php 如何在wordpress中将较旧的帖子移动到另一个类别,php,wordpress,archive,wp-list-categories,Php,Wordpress,Archive,Wp List Categories,我想为以下要求创建自定义存档模板 我在管理面板设置中设置了一个配置,管理员可以从中设置存档新闻的时间段。 当从管理员端应用新的时间段时,它应在CMS中的新闻项目上运行,并自动将比时间段(即:30天)早的新闻项目添加到存档类别中。在新闻列表页面上,只应显示不在存档类别中的新闻项。单击“查看存档新闻”按钮时,将显示一个新页面,该页面的模板与新闻列表页面相同,但显示存档新闻类别中的所有新闻项 例如:如果我有10篇文章的类别为“新闻”,现在如果我从后端设置中设置存档天数=10,那么在10天后,所有超过1

我想为以下要求创建自定义存档模板

我在管理面板设置中设置了一个配置,管理员可以从中设置存档新闻的时间段。

当从管理员端应用新的时间段时,它应在CMS中的新闻项目上运行,并自动将比时间段(即:30天)早的新闻项目添加到存档类别中。在新闻列表页面上,只应显示不在存档类别中的新闻项。单击“查看存档新闻”按钮时,将显示一个新页面,该页面的模板与新闻列表页面相同,但显示存档新闻类别中的所有新闻项

例如:如果我有10篇文章的类别为“新闻”,现在如果我从后端设置中设置存档天数=10,那么在10天后,所有超过10天的文章都会自动分配新的类别为“类别存档”。

更新:

function custome_archive_news($posts_array){

    foreach($posts_array as $key => $postVal){

    $slug = $posts_array->post_name; 

        $today = date("r");
        $articledate = date('r',strtotime($postVal->post_date));

        $difference = round((strtotime($today) - strtotime($articledate))/(24*60*60),0);

                if ($difference >= 30) {

                  wp_set_post_terms( $postVal->ID,'archivecategory','category',false);

                }

        }

    }
谁能帮我一下吗

谢谢,
Chandresh

你能给我看一下(代码)到目前为止你都尝试了什么吗?@Mangeshpart:我在我的问题中添加了一个代码,请检查。