Hello,
My old theme used the “the_excerpt()” function to control excerpt length and now I have discovered that this is not the way it’s done in the Newspaper theme. So now all my excerpts appear too long. I am fine with the control I have for the homepage but I would like to add the “the_excerpt()” for my categories. I am using M16 so it shouldn’t take much for me to add some code. Somebody already asked a similar question and you told them what to do so it should be easy. Thank you for your help.
-
This topic was modified 11 years by
centennia.
Hi,
You can set the excerpt length for each module from Theme Panel > Excerpt section – http://screencast.com/t/xW6LP6ujaFO
If you want to create a condition for module 16 excerpt lenght only for category page you ca add it like this – http://screencast.com/t/IxPxKkZmukH
<?php
if (is_category ()) {
echo $this->get_excerpt(2);
}
else{
echo $this->get_excerpt();
}
?>
Result
– category – http://screencast.com/t/pHZCBvJkG4HX
– other template where module 16 is used – http://screencast.com/t/RGKvlVlYAhxE
Thanks!
-
This reply was modified 11 years by
Alin [tagDiv].
Not working, I’m afraid.
http://screencast.com/t/ICVeBxkkM
And I correctly used M16: http://screencast.com/t/uPsPS18O4Zf
-
This reply was modified 11 years by
centennia.
Hi,
Please provide a link to category page where you use module 16 as it should work fine I have checked this again – http://screencast.com/t/CpRQeL61Hg – http://screencast.com/t/HMjSM7zqo Also please clear cache may it is a caching issue.
Thanks!
I can’t provide you with a link because I am using a local installation. I found this other code, <?php echo wp_trim_words(get_the_excerpt(), 30); ?> , which I then put in M16 like this:
<div class=”td-excerpt”>
<?php echo wp_trim_words(get_the_excerpt(), 30); ?>
</div>
It works but I am not sure if it is good practice. Should I add anything else? Thanks!
Hi,
You can use it without any problems if it is working for you.
Thanks!