Remove post content on front page only?


I am building a news blog, using the Beans Starter Charter theme. I only want the post images and titles to display on the front page, in a grid. No excerpts. Just the images and the clickable titles.

I managed to get everything working by using the code snippets "Display posts in a responsive grid", "Move the post image above the post title", "Remove the post meta", and "Remove the post content" at the bottom of my functions.php.

Everything looks great. The only problem is that the "Remove the post content" code snippet also removes the content (the article's text) from the actual post on it's page.

I was wondering if there was a way to display only the post's titles on the front page, but also show the whole content on the page of the actual post.

Do I need to modify a sample-template.php or make a page.php that will override the code snippet in the functions.php, or is there any easier way to do this, by using a code snippet?

Any help would be most appreciated. I am really loving the Beans Framework so far. Thank you.


SOLVED! I managed to fix it by creating an index.php, and placing the code snippet "Remove post content" there, so that it did not affect the individual post pages. Now, it is working beautifully.


Hey Dave,

index.php is a risky one, as it is used as a fallback for other pages such as author page, archive page, category page etc...

If you want to modify only the front page, then create front-page.php instead of using index.php.

Cheers!


Thanks much, Joseph. I will create a front-page.php, and use that instead.

There is really a great and helpful community here.


In your functions.php use this:

if ( is_front_page() ) {
    // Remove post content
    beans_remove_action( 'beans_post_content' );
}

m


Thank you, Mike. I appreciate the help.

Write a reply

Login or register to write a reply, it's free!