Last active
February 26, 2016 06:09
-
-
Save lenivene/ec6bcba5d73d632e0dd7 to your computer and use it in GitHub Desktop.
get_the_excerpt by ID post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filter from "the_excerpt". | |
* | |
* @since 1.0.0 | |
* @param string $post_excerpt The post excerpt. | |
* | |
*/ | |
function get_excerpt_by_ID( $post = 0){ | |
$post = get_post( $post ); | |
if ( empty( $post ) ) { | |
return ''; | |
} | |
if ( post_password_required() ) { | |
return __( 'There is no excerpt because this is a protected post.' ); | |
} | |
return apply_filters( 'get_the_excerpt', $post->post_excerpt ); | |
} | |
/** | |
* Filter the displayed post excerpt. | |
* | |
* @since 1.0.0 | |
* @see get_excerpt_by_ID() | |
* @param string $post_excerpt The post excerpt. | |
* | |
*/ | |
function the_excerpt_by_ID( $post = 0){ | |
echo apply_filters( 'the_excerpt', get_excerpt_by_ID( $post ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment