Skip Navigation

[Resolved] ‘Read More’ block not recognized in blog posts WordPress Archive View

This thread is resolved. Here is a description of the problem and solution.

Problem:
'Read More' block not recognized in blog posts WordPress Archive View - Limit the post body content and display on frontend

Solution:
To limit the post body content with number of character/words and display it on frontend, you need to write your own custom code.

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/read-more-block-not-recognized-in-blog-posts-wordpress-archive-view/#post-1996483

Relevant Documentation:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 10 replies, has 2 voices.

Last updated by Anthony 3 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#1995217

I am displaying the blog posts for this site in a WordPress Archives Block using just the 'Post Content (Body)' Post Field in the WordPress Archive Loop and the Masonry Loop Style.

You can see the current result at hidden link .

I expected to see only the post content up to the 'More' blocks inserted in each post to be displayed.

Instead, the entire post content (body) of each post is displayed.

#1995709

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Currently, this issue is known to us and there is no way to parse the read more block (tag).

We can display the post excerpt but if we will go with that it will not display the image as expert do not recognise the image.

What I suggest is you should setup a featured image but if all post content is already setup then it will not be a good idea to go through all the posts and update related featured image for every post.

I suggest you should use some filter or hook or custom shortcode that should help you to parse the "more" tag you added before displaying the content on frontend.

or

another workaround would be we can create a shortcode that should limit the post body content up 300-500 characters and we should add the read more link , when we click on read more link that should redirect user to the single post.

#1995753

Thank you for your reply, Minesh. I'm disappointed to learn it's a known issue; I hope that sometime in the future Toolset will be able to parse the Read More tag!

The problem with using the post excerpt (besides needing to convert embedded images in existing posts to featured images) is that the current maximum limit of 30 words is much less than wanted in this use case. So I'm very interested in your idea of a shortcode to limit the post body content length if that could be to 300-500 words or 1500-2500 characters, but I'm not sure how to proceed. Can you show me how to accomplish this?

#1996167

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I tried all possible ways but it just not working as expected as the image is added to the post body, we can not have real count of words or characters as well as when I do count of character or word the image added to post body is stirp out.

I do not have any other solution to offer at the moment.

Here is the related ticket that may help you to count characters:
=> https://toolset.com/forums/topic/limit-characters-display-in-view-for-custom-wysiwyg-field/

#1996393

I can strip the embedded images out of the post body and make them featured images, so the post body will contain only text. Will one of your possible ways work in that case?

#1996399

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If you setup a featured image then what you need to do is.

You should setup your loop output as:
- Add image block that will help you to display featured image
- Add single field block and with that you should display the post excerpt with this you can control how many words you want to display
- if you do not want to display the post body content using excerpt, then yes, one of the solution I shared will work

#1996403

I'm a bit confused. I'm now displaying the post featured image. But I don't want to use the post excerpt because it won't let me display 1500-2500 characters. I want to use the post body but with the limit shortcode - how do I do that?

#1996443

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

But you have to setup the value for the featured image then and then the image will get displayed.

For instance, check the following post, there is a Featured Image tab on right side bar, there you need to upload the image, then you can able to display the Featured Image on frontend.
=> hidden link

I hope that you understand that for every post you have to setup the featured image.

#1996483

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the following code to "Custom Code" section offered by Toolset:
=> hidden link

add_shortcode('limit_content', 'func_limit_body_content');
function func_limit_body_content($atts, $content = '') {
  global $post;
  $post_data = get_post($atts['post_id']);
  return $fielddata = wp_trim_words( $post_data->post_content,200)."<a href='".get_permalink($atts['post_id'])."'>Read More </a>";
   $fielddata = $postcontent;
}

For now, I've setup the length of 200 words, you can adjust as per your requirement.

#1997023

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please confirm that the solution I shared help you to resolve your issue 🙂

#1997755

My issue is resolved now. Thank you!