Add the below code at the end of your theme’s functions.php file or you can also add the below code inside your site-specific plugin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /** * Display specific content only for logged in users. */ function content_only4logged_in($content) { // ALL LOGGED IN USERS if ( is_user_logged_in() && !is_null($content) && !is_feed() ) { return $content; } else { $content = wp_html_excerpt( $content, 80 ); $content .= ' …'; $content .= __( 'Sorry, more of this content is only available for logged users.', FB_TEXTDOMAIN ); return $content; } } add_action( 'the_content', 'content_only4logged_in' ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.