Easiest way to have closed comments on a custom post type

Template Tags for the rescue Only logged in users: is_user_logged_in() Only logged in users that have a certain capability assigned to their role current_user_can($capability) Only logged in users that have a specific role assigned current_user_has_role($role) Only logged in users that have a specific capability assigned (to their role) on a specific blog current_user_can_for_blog($blog_id, $capability)

How can I create an RSS feed that includes “Private” posts?

I assume your theme already has a ‘feed-rss.php’ (if not, here’s how they work: http://codex.wordpress.org/Customizing_Feeds) You’ll need to pass a few parameters to the query before you loop through them. //Get all posts that are private or public $the_query = new WP_Query( array( ‘post_status’ => array( ‘private’, ‘publish’ ) ); while ( $the_query->have_posts() ) { … Read more

Have custom post type Visibility be private by default, and have radio button also set to “Private”

Actually all you have to do is changing the script part to this: <script type=”text/javascript”> (function($){ try { $(‘#post-visibility-display’).text(‘<?php echo $visibility_trans; ?>’); $(‘#hidden-post-visibility’).val(‘<?php echo $visibility; ?>’); $(‘#visibility-radio-<?php echo $visibility; ?>’).attr(‘checked’, true); } catch(err){} }) (jQuery); </script> You see there is an additional line compared to your code. I’m referring you to my original answer for … Read more

Hide public page from logged in users?

You can create a page template to check if user is loggedin. And if it does then redirect user to website homepage (configurable), otherwise show page content. This is the simple condition you can use to check if user is loggedin. <?php if ( is_user_logged_in() ) { wp_redirect( home_url( “https://wordpress.stackexchange.com/” ) ); exit; } else … Read more

Private Post BUT Public excerpt on Homepage

You could add this to your themes functions.php file. This adds private posts to the initial loop on the homepage only. /** * Include private posts in homepage loop */ function show_private_posts_on_homepage($query) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘post_status’, array( ‘publish’, ‘private’ ) ); } } add_action(‘pre_get_posts’, ‘show_private_posts_on_homepage’); Depending on your theme, … Read more

Private post hidden from Admin too

By default, WordPress posts set to private are visible to admins, and you can distinguish them on the frontend because they have ‘Private:’ prepended to their title. However, you might have plugins installed that are modifying this behaviour. It could be your capability management plugin, or it could be WooCommerce. The specifics of third-party plugins … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)