1. Home
  2. Knowledge Base
  3. Posts Table Pro
  4. Advanced Usage

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.

We've partnered with Codeable to provide our customers with expert help if required.

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 post_table shortcode.

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:

// Get the user's ID
$user_id = get_current_user_id();

// Insert the ID into the shortcode
echo do_shortcode('[posts_table author="' . $user_id . '"]'); 

Now, when you open a page that uses this template, the posts table will only display posts by the current user.

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.