How to exclude password protected posts in WP_Query

if(!current_user_can('edit_pages')) { // Exclude all passwd protected posts for non-authorized level users $args['perm'] = 'readable'; $args['has_password'] = false; // Make sure }

Only the perm should suffice, but it does not work in all situations. To make sure we add the has_password argument.
This snippit will allow all logged in users who have capabilities to edit a page to see the title of a password protected post. All others (subscribers and non logged in users, will not se the title of the protected post at all).


Samenwerken doen we graag!

We werken graag op freelance basis. Ook voor andere web-bureau's en ontwikkelaars.
En dat mag ook op whitelabel basis. Doen we niet moeilijk over.

Bekijk de informatie pagina.