• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

Post on Pages - Is it possible to show post previews with content limit on pages ?

I have a blog and on the home page i have a featured posts widget (set to display the latest post from any catagory) with a content limit of 300 characters. This widget also displays a thumnnail of the Featured image.

I would like to have the same Featured post to work on Pages.

To get Posts on Pages i have done the following ..

I have created a catagory called - Reviews (Catagory id is =5)
I then created a Page also Called - Reviews

On the Reviews page i selected the Template - Blog

In Custom Fields i used:

query_args       cat=5

This allows me to create a new post and select the catagory Reviews. The post appears on my homepage within featured posts widget and also appears on the Reviews Page.

My problem is that the entire post appears on the Reviews page. As you can imagine, after 3 or 4 posts the page gets very long.

I want to only display a preview of the post with featured image on the Review Page, the same as it does on the home page. Then if a visitor wants to see more of the posts they click on a 'Read More' link. That way i will be able to display more than just 3 or 4 long posts before they fall of the bottom of the page.

Thank you for your time.
0
rookeydooks
Asked:
rookeydooks
  • 2
  • 2
1 Solution
 
Jason C. LevineNo oneCommented:
>> My problem is that the entire post appears on the Reviews page.

If you look at the code, it's retrieving the function the_content() which is everything in the post(s).  You either want to use the_excerpt() or use the <!--more--> tag in the posts so that it cuts off at the tag when presented in the loop.
0
 
rookeydooksAuthor Commented:
Hi jason1178, which file has the code i need to look at ?
0
 
Jason C. LevineNo oneCommented:
It would be your blog template file in the theme.
0
 
gwkgCommented:
You could put this function your functions.php file

<?php  

  function dooks_pageContentFilter($content)
  {
    return substr($content, 0, 300);
  }

?>

and then add

<?php  

if ( in_category( 'reviews' ) )
    add_filter( "the_content",  "dooks_pageContentFilter" );

?>

to your blog template file.
0
 
gwkgCommented:
Using <!--more-->  in your original post, like jason said, is a simpler way to have the Read More link show.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now