Permalink
Browse files

Update wfx_excerpt() function - new ‘id’ param

New parameter ‘id’ for wfx_excerpt() - allows excerpt to be called anywhere (not just inside loop/query).
  • Loading branch information...
1 parent c7f1ac3 commit f431c7fd8601569002162a2a974080cf2e94927b @Jonnyauk committed Dec 5, 2016
Showing with 7 additions and 2 deletions.
  1. +1 −0 functions.php
  2. +6 −2 wf-includes/wf-display-functions.php
View
@@ -1080,6 +1080,7 @@
* @param [string] $excerpt_end Characters to add to end of the excerpt. [...]
* @param [string] $trim Trim off punctuation from end of excerpt - good when you don't want it to bump into your excerpt end. Y/N [Y]
* @param [string] $full_excerpt If an actual excerpt is set (not an excerpt of post content) - display whole except. Ignores $limit, $excerpt_end & $trim params. Y/N [N]
+ * @param [int] $id Optional, set specific post ID if using outside the loop - defaults to loop post ID if not set. [null]
* @param [string] $echo Echo or return output. Y/N [Y]
*/
if ( !function_exists( 'wfx_excerpt' ) ) : function wfx_excerpt($args) {
@@ -1576,20 +1576,24 @@ private function get_clean_theme_name() {
* @param [string] $excerpt_end Characters to add to end of the excerpt. [...]
* @param [string] $trim Trim off punctuation from end of excerpt - good when you don't want it to bump into your excerpt end. Y/N [Y]
* @param [string] $full_excerpt If an actual excerpt is set (not an excerpt of post content) - display whole except. Ignores $limit, $excerpt_end & $trim params. Y/N [N]
+ * @param [int] $id Optional, set specific post ID if using outside the loop - defaults to loop post ID if not set. [null]
*/
function wf_excerpt($args) {
$defaults = array (
'limit' => 20,
'excerpt_end' => '...',
'trim' => 'Y',
- 'full_excerpt' => 'N'
+ 'full_excerpt' => 'N',
+ 'id' => null
);
$args = wp_parse_args( $args, $defaults );
extract( $args, EXTR_SKIP );
- $content = get_the_excerpt();
+ $id = ( is_numeric($id) ) ? $id : null;
+
+ $content = get_the_excerpt( $id );
if ( has_excerpt() && $full_excerpt == 'Y' ) {

0 comments on commit f431c7f

Please sign in to comment.