admin管理员组文章数量:1431904
I am trying to update all the WP post title and content then show the just updated post to a table. I am using the following code but it does not work:
$args = array(
'post_type' => 'post',
'numberposts' => -1
);
$myposts = get_posts($args);
foreach ($myposts as $mypost){
$mypost->post_title = $mypost->post_title.'test';
wp_update_post( $mypost );
echo "<td>".$mypost->post-title.""."</td>";
}
Also, as I am trying to update all the posts which might have timeout error or server timeout. How to display this action with AJAX or jQuery or anything to perform one by one then sleep?
I am trying to update all the WP post title and content then show the just updated post to a table. I am using the following code but it does not work:
$args = array(
'post_type' => 'post',
'numberposts' => -1
);
$myposts = get_posts($args);
foreach ($myposts as $mypost){
$mypost->post_title = $mypost->post_title.'test';
wp_update_post( $mypost );
echo "<td>".$mypost->post-title.""."</td>";
}
Also, as I am trying to update all the posts which might have timeout error or server timeout. How to display this action with AJAX or jQuery or anything to perform one by one then sleep?
Share Improve this question edited Apr 15, 2019 at 12:26 Nicolai Grossherr 18.9k8 gold badges64 silver badges109 bronze badges asked Apr 15, 2019 at 11:37 David NguyenDavid Nguyen 1 1- It does not work is not a good descriptor, and not that well received, it's better to be more specific. After all, you want people to take time out of their day to help you, so better be forthcoming. Additionally, a question is supposed to contain one specific problem, so answers are clearly aimed at that. It's not a problem to ask multiple questions, and link to the other ones, but make their quality good. To get familiar with the guidelines of this community give the help center sections regarding those a good read. – Nicolai Grossherr Commented Apr 15, 2019 at 12:41
1 Answer
Reset to default 0For a process this large you are probably running up against timeout errors. You can either set your server's timeout to a very, very large number (not recommended) or use a different process to achieve these results.
Take a look at writing a command using WP CLI or adding a scheduled task to allow the server to run these in the background.
You may have to handle which posts have already been updated and skip those if this process needs to occur more than once.
Best of luck!
本文标签: Update all WordPress posts39s title and content then display them in a table
版权声明:本文标题:Update all WordPress posts's title and content then display them in a table 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745586352a2664929.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论