Published on Sep 2, 2020

How to Display Posts of the Logged-in User in Oxygen

Sridhar Katakam

This members-only tutorial provides the steps to show only the entries written by the currently logged in user of a Custom Post Type on the CPT archive.

We shall set up an archive Template in Oxygen for entries of a workout CPT, create two Sections - one for logged-in users and another for visitors. The first Section for logged-in users will contain an Easy Posts component with the default query and the other Section for non-logged-in visitors will simply show a message that the user should be logged in to see the content of the page.

Then we shall use pre_get_posts to filter the posts by the author whose ID matches that of the logged-in user.

Step 1

If you have not already, register your CPT using a plugin like CPT UI.

Set "Has Archive" to True and type your desired slug for the CPT archive page. In this case: workouts .

In the "Supports" setting, tick "Author".

Add your CPT entries and ensure there are multiple posts authored by different users.

Step 2

Create a Template that applies to your CPT archive.

Edit it with Oxygen.

Add a Section.

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $499 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right