• Hello All,

    I have a custom post type which each user is able to edit one of. I want to make it so each user can only see the post they can edit since there are two pages of posts and it takes a long time to find a specific post.

    I’m presuming I would have to use a filter but I’m not really sure where I would go from there. All guidance/assistance will be greatly appreciated.

    Thanks everyone.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You use an action actually, ‘restrict_manage_posts’. The post type is passed as a parameter to your callback. From your callback, if the post type is correct, output a dropdown form field named ‘author’. The first option would be ‘All Authors’ with a empty string value. Then list the other authors, each with their ID as the option value. wp_dropdown_users() should get you pretty close to the needed output, though some adjustment may be required through the ‘wp_dropdown_users’ filter.

    How this works is your author dropdown appears along with the other dropdown filters like date and category. When an author is selected (let’s say the selected ID is 5) and the ‘Filter’ button is clicked, a GET request is sent with &author=5 appended to the URL. The page already knows how to deal with an “author” query argument from the existing ‘click-on-author-name-to-filter’ functionality. You are just providing an alternate way to add the same argument.

Viewing 1 replies (of 1 total)
  • The topic ‘Hide Some Custom Posts’ is closed to new replies.