If you have troubles since the update to WordPress 4.5 please read this post before opening a new thread.
Hi could someone help me with the latest blog page? I need every blog article to be trimmed. Let’s say trim 300 words and after that a read more link shows up. I know I could apply the read more tag in the article but i’ve got more than 100 articles and there must be a sort of function to create what I need right?
In the current situation all the blog posts fully shows up now instead of a part of it.
Hope someone could help me out.
Edit a post then go to the end of a certain paragraph that you want to show as an excerpt. Add this code below.
This will strip away all of the text below and create a Read more link.
Like I said in the previous comment, I know I can do that, but since I have more than 100 articles I need a kind of function to apply this to every article. For example lets say, trim the text after 100 words.
I a piece of code, but it trims the whole blog article instead of giving a preview with a read more link.
Could you give me advise how to integrate this?
I used this piece of code in includes/loop-index.php
$current_post = wp_trim_words( get_the_content(), 100);
Dead on with your change to the main loop. Since 3.3 the wp_trim_words is the best way to do that instead of the old functions that filter through the content.
The problem is that when I implement this function in $current_post, that all the content in the site gets trimmed. Not only the blog index “preview” page. Where do I need to put this function? In loop-index.php right?
Please try to use a conditional like:
$current_post['content'] = is_single() ? get_the_content() : wp_trim_words( get_the_content(), 100);
The topic ‘Trim blog page text.’ is closed to new replies.