Here is a code that will display of password protected post/page of wordpress. Use this in function.php
<?php
function display_protected_excerpts($excerpt)
{
global $post;
if (!empty($post->post_password)) {
$output = $post->post_excerpt;
$output = apply_filters(‘get_the_excerpt’, $output);
return $output;
}
return $excerpt;
}
add_filter(‘the_excerpt’,’display_protected_excerpts’, 0);
function display_excerpt_on_protected_posts($content)
{
global $post;
$replacement_text = $post->post_excerpt;
$replacement_text = apply_filters(‘get_the_excerpt’, $replacement_text);
return str_replace(‘This post is password protected. To view it please enter your password below:’,$replacement_text, $content);
}
add_filter(‘the_content’,’display_excerpt_on_protected_posts’, 10);
?>
More Post
Effective SMM Panel Strategies for Driving Website Visitors in Nepal
How to add 360 photos in wordpress with solution
How Dangerous Is Trekking To Everest Base Camp In 2023 ? | Best Travel Tips & Advice