Get published posts and pages?

Question

I’m working on a plugin to use gettext in posts and pages content.

I’m trying to get all published posts and pages in order scan them for translatable strings, but I cannot figure out how to do it.

This is what I’m trying:

$pages = $wpdb->query('SELECT * FROM wp_posts WHERE post_status = "publish"');
foreach ( $pages as $post ) {
    print_r($post);
}
0
Lisandro Vaccaro 5 months 2020-12-19T10:10:29-05:00 0 Answers 9 views 0

Leave an answer

Browse
Browse