Hi guys.
I want to add a "lock" in the excerpt of a post if the post is password protected.
Do someone know a way to know, in a loop, if the post is password protected?
How do I force WP to show me the excerpt of a Password-Protected post?
Hi guys.
I want to add a "lock" in the excerpt of a post if the post is password protected.
Do someone know a way to know, in a loop, if the post is password protected?
How do I force WP to show me the excerpt of a Password-Protected post?
Got this from http://comox.textdrive.com/pipermail/wp-testers/2008-November/010138.html
<?php
if (!empty($post->post_password)) { // if there's a password
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
echo 'display of excerpt:' . $post->post_excerpt;
}
}
?>The "if" block works, it understands if a post is password protected.
However $post->post_excerpt;
is empty.
Do someone knows why? Do I have to take some global variable before this code?
Could be you are talking about the 'manufactured' Excerpt so use template tag, the_excerpt() instead.
This topic has been closed to new replies.