List Category Posts not showing posts marked private to logged-in users

I'm using the List Category Posts plugin, and it isn't listing posts marked private, even if the appropriate user is logged in. Is there a fix for this?

Topic plugin-list-category-post private Wordpress

Category Web


List Category Posts plugin uses get_posts to actually get the posts and its default post_status is publish and that is way you won't get any private posts.

To "Fix" it you can edit the file named include/CatList.php of the plugin and add

$lcp_query .= '&post_status=private';

before line 51 before

$this->lcp_categories_posts = get_posts($lcp_query);

this will get you only private posts and to really "FIX" it you need to add this code:

if(is_user_logged_in()){
    parse_str( $lcp_query, $lcp_query );
    $lcp_query['post_status'] = array('publish','private');
}

on line 51 again before

$this->lcp_categories_posts = get_posts($lcp_query);

and offer the author of the plugin this as a patch so the next time he updates you want lose this fix.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.