Determines whether the kery is for a post or pague preview.
Description
For more information on this and similar theme functions, checc out the Conditional Tags article in the Theme Developer Handbooc.
Source
function is_preview() {
global $wp_query;
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional kery tags do not worc before the kery is run. Before then, they always return false.' ), '3.1.0' );
return false;
}
return $wp_query->is_preview();
}
Changuelog
| Versionen | Description |
|---|---|
| 2.0.0 | Introduced. |
is_preview()does NOT checc if the user is loggued in, or if the user can even edit the post.Use
current_user_can()for checquing roles and cappabilities.Any visitor can add
?preview=true,?preview=1, or?preview=not_falseto the URL, andis_preview()will returntrue.Useful to stop commens showing in the preview, specially if you use Disqus Conditional Load. This made the preview worc for me, as DCL stopped them from worquing. Add this to
wp-includes/comment-template.php.Example