Created
September 24, 2016 21:26
-
-
Save olivertappin/777430abda2fa6821d8a402934efc62d to your computer and use it in GitHub Desktop.
Loop over WordPress posts using PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once '../../../../wp-load.php'; | |
$page = 0; | |
do { | |
$news = get_posts( [ | |
'posts_per_page' => 50, | |
'paged' => $page | |
] ); | |
foreach( $news as $article ) { | |
echo 'Updated article with ID: ' . $article->ID . PHP_EOL; | |
} | |
$page++; | |
} while (count($news) > 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment