Reputation: 209
Is it possible to have just one hard-coded Excerpt in word-press for all posts and pages?
What i have read so far is that i need to change index.php and archive.php file.
But am not sure whats the best way of doing this. Or can i build a function for it?
I want the same Excerpt for all posts/pages.
Or if there is some plug-in that does this.
The code i have found that i need to replace is
<?php the_excerpt(); ?>
Replace to
<?php if (function_exists(‘has_excerpt’) && has_excerpt()) the_excerpt(); ?>
But i cant find in what files i have checked my index.php,page.php,header.php
I am using TwentyEleven as theme.
Upvotes: 0
Views: 116
Reputation: 1196
Here are two examples
<?php
// Get particular post's excerpt
$my_post = get_post('some-Post-ID');
echo $my_post->post_excerpt;
?>
or
<?php
if ( is_category() || is_archive() ) {
the_excerpt();
}
?>
But I believe you need same excerpt for all your posts hence you should print a common static excerpt.
Upvotes: 0
Reputation: 1196
If you need a common excerpt then just hard code it wherever you want to display it.
Instead of the_excerpt();
just write your hard coded excerpt for example
<div>This is my sample static excerpt</div>
That's it.
Upvotes: 2