Showing the post password form for excerpts in WordPress
June 27, 2009
Many WordPress themes show excerpts on the front page and other archive-type views. When viewing a password-protected post, this message is displayed: There is no excerpt because this is a protected post. While this is fine for many scenarios, it may not be the most helpful piece of text for the average Internet user. Instead of showing the message, we’ll replace it with a password form. Replacing the no excerpt text with a password form WordPress comes packaged with a neat function called get_the_password_form() that... [Read the full story]
Replacing WordPress content with an excerpt without editing theme files
May 14, 2009
Let’s suppose our front page and archives used the WordPress function <?php the_content(); ?> to retrieve all post content. Let’s further suppose we’re want to modify this with a child theme to show excerpts instead of the entire post. We could easily just change <?php the_content(); ?> to <?php the_excerpt(); ?>. But, We don’t want to edit the core files at all. We want to be able to upgrade our theme without our modifications being broken. The Solution is: WordPress filters. In our child theme’s... [Read the full story]
Remove the suffix dot from the excerpt
March 14, 2009
Did you ever wondered why the the_excerpt() function always display [...] at the end of the post excerpt? To be honest, I don’t find this very beautiful. So, what about remove it? To get rid of the [...] at the end of the post excerpt, simply paste the following function in the functions.php file from your theme: function trim_excerpt($text) { return rtrim($text,'[...]‘); } add_filter(’get_the_excerpt’, ‘trim_excerpt’); Read More →
Manually define to show full post or excerpt on your homepage
January 23, 2009
Do you use excerpts or full posts on your blog excerpts? Personnally, I think they’re both good. The only problem is that you can’t, by default, use both excerpts and full posts on your blog homepage. Here’s a code to do it. On your index.php file, replace your current loop by this one: <?php if (have_posts()) : while (have_posts()) : the_post(); $customField = get_post_custom_values("full"); if (isset($customField[0])) { //Custom field is set, display a full post ... [Read the full story]
Check out if a wordpress post has an excerpt
December 9, 2008
How to be able to know if a specific post has an excerpt? It may seems hard at first because there’s no built-in WordPress function to achieve it, but we got this useful code which make it possible. To check out if a post has an excerpt, simply paste the following code within the loop: <?php if(!empty($post->post_excerpt)) { //This post have an excerpt, let's display it the_excerpt(); } else { // This post have no excerpt } ?> Read More →




















