How to exclude password protected posts in WP_Query Blog

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).


Suggestie? Vraag of opmerking? Laat het ons weten!

Plaats hier je bericht

Reacties (0)