How to include private posts in overview of posts for author

Support MB Views How to include private posts in overview of posts for authorResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36028
    EddyPiVEddyPiV
    Participant

    Hi,

    I need to show an overview of all private posts of the current user. I have the following code:
    <div>
    {% set user_ID = mb.get_current_user_id() %}
    {% set args = { post_type: 'fantask', meta_key: 'training_post_id', meta_value: '300', author: user_ID, numberposts: 10, post_status: 'private', order: 'asc' } %}
    {% set posts = mb.get_posts( args ) %}
    </div>

    I only get the public published posts.

    How to get the private posts?

    #36035
    Long NguyenLong Nguyen
    Moderator

    Hi Eddy,

    There is no parameter numberposts, it should be posts_per_page. Other parameters look good, so you can check if there is a private post that has the post meta training_post_id and value 300.

    Read more about query parameters here https://developer.wordpress.org/reference/classes/wp_query/

    #36039
    EddyPiVEddyPiV
    Participant

    Hi Long, apparently both posts_per_page and numberpost work, but I changed according to your advise.
    Yes, private posts are showing now.

    Thanks, working fine.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.