I've been trying to get the latest Page, not post, by author ID and display it on a page.
The reason it has to be a page and not a post is that the user will only be posting one page and a whole bunch of posts.
This also needs to be done dynamically and be based on the current logged in user.
I've got the following code:
<?php
$user_id = get_current_user_id();
echo $user_id;
$args = array(
'post_type' => 'page',
'post_status' => 'published',
'posts_per_page' => 1,
'author' => $user_id
);
$my_posts = get_posts( $args );
foreach ( $my_posts as $post ) : setup_postdata( $post ); ?>
<?php the_title(); ?>
<?php endforeach; ?>
All this does is return the title of the current page (testing with the_title(); will replace with the_content(); once it starts working). I've looked around for solutions but can't find any.
Would love some help with this.