List posts by current user only
Posts Table Pro allows you to list WordPress posts by specific authors using the author option in the
[posts_table] shortcode. Alternatively, perhaps you’d like to display posts by the current user only. This is possible with some custom code.
Please note that this code is aimed at developers and if you don’t know how to use it then you should ask your developer. in particular, this article presupposes some familiarity with WordPress’ template system. You can find out more about templates here. If you don’t have a developer who can help you with this, then we recommend posting a job on Codeable. We have partnered with them to provide plugin customizations for our customers.
Listing posts by the current user
To display posts by the current author, you’ll need to add some custom code to one of your child theme’s templates (why use a child theme?). This will allow you to get the current user’s ID programmatically then insert that into the
Open your template file in a code editor and click to the point where you’d like the posts list to appear. Insert this code:
$user_id = get_current_user_id(); // Get the user's ID echo do_shortcode('[posts_table author="' . $user_id . '"]'); // Insert the ID into the shortcode
Now, when you open a page that uses this template, the posts table will only display posts by the current user.