#4177 closed enhancement (fixed)
new conditional tag: has_excerpt
Reported by: | FekketCantenel | Owned by: | rob1n |
---|---|---|---|
Milestone: | 2.3 | Priority: | normal |
Severity: | trivial | Version: | |
Component: | Template | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Here is a short suggestion for a new conditional tag in query.php. Before this is added, or in case it never is, I've added a short help to the Conditional Tags documentation.
function has_excerpt () { global $post; if (empty($post->post_excerpt)) { return false; } else { return true; } }
I know that this appears very simple, but PHP newbies (like myself) wouldn't think of it without help. The function it serves doesn't seem that obscure, so I hope it's worthy of inclusion.
Attachments (1)
Change History (14)
#2
@
17 years ago
- Keywords has-patch 2nd-opinion added
- Milestone set to 2.3
Makes sense to me, I guess. +1.
#9
@
17 years ago
Just curious, why is the patch code so different from what I wrote? It's in a different file, looks a bit different... I ask for future reference.
#10
@
17 years ago
FekketCantenel,
For increased usefulness. Your code would only work with the current post. This function can take any post ID as a parameter. The return line is just simpler... skips the if/else logic block and just returns the opposite of the empty() bool result.
#11
@
17 years ago
"Your code would only work with the current post. This function can take any post ID as a parameter."
Ahhhhhhhh, I see. So this way, you could write has_excerpt('1') (the post's ID) and find out if that post has an excerpt. It's a good thing you thought of that.
Thanks for the information.
#12
@
17 years ago
Also, this function was put into post-template.php because it is a template tag that deals with posts. query.php is usually reserved for functions that are directly related to WP_Query (is_page, is_home, etc.).
Looks like a good idea for a conditional tag.