Could we help you? Please click the banners. We are young and desperately need the money
In this quick guide, I'll show you how to get WordPress Posts.
To get posts, use this function:
get_posts();
If you want to get posts by arguments, first, create an array:
$args = array(
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
'post_type' => '{insert_post_type}',
'post_status' => 'publish'
);
The example shows some arguments you can use, be sure to set the values to what you need them to be. For a full list of arguments, check out the offical WordPress Documentation here (get_posts() specific) and here (WP_Query in general).
Now, pass on the arguments to the function like this:
get_posts($args);
You might want to get each post you have retrieved, this is how you do it:
$retrieved_posts = get_posts($args);
foreach ($retrieved_posts as $key => $single_retrieved_post) {
//this is a single post
echo ($single_retrieved_post->post_content);
}
In this example, we even echo the post's content. If you want to do something else with it, just remove that line of code.