Site logo

Archived topic

Customizing Blog Templage For Only Home Page

8 replies · Started by Bud on October 8, 2018

Viewing posts 1–9 of 9

Hi Tom

Very new to GP but I love it. I can't believe the features you have packed into it. You really understand what people need and are light years ahead of everyone.

Your documentation is amazing. I looked everywhere for an answer to my question before I contacted you.

I'm handy with CSS not so much with PHP.

I'm working on a site that uses the standard blog template for the home page which is set to latest post. I have several category archive pages as well.

How do I change the blog template so that it will not display a sidebar and in its place I want to add a video just for the home page? (I want to leave the blog template as is for the category archive pages.)

Thank you so much.

Bud

Hi David

Thanks for your quick response but that's not the answer because we're not dealing with a page but the post template. Seems like you need to add a filter or an action in functions.php to get this done.

I am familiar with Content Aware Sidebars but that won't work for the same reason. i needto modify the blog template (probably index.php) which - as you know - has nothing to do with pages.

Bud

The Layout Element allows you to disable elements even on archives / blog pages / front page. Its not restricted like the meta box in the page editor. Problem is in removing the sidebar also removes the before_sidebar_content hook so we can't add the video there.

I am not sure what the problem is with using a dynamic sidebar plugin? You could set the video to be only displayed for the front page and set the condtions for the other widgets?

David

I tried that before but ti does not work,

Here is what I just did.

1. Created a page and called it "blog"
2. Chose that page to be my post page. (I did not select any page to be Home Page as I need that to be the Home Page.
3. Tried changing to Layout options like no sidebars or sidebar/content but no matter which option is picked I get the default (content/sidebar).

Am I doing what you suggested?

If so, I will look into using CAS.

Bud

No need to reply for now.

Just had a look at CAS which I have used and I think that will do the trick.

IF not, I'll have to get back to you.

Thanks for your help.

Bud

You're welcome - keep us posted :)

David

Here is what I did after seeing the doc on sidebars.

#Removes sidebar home page (blog)

add_filter( 'generate_sidebar_layout','bk_custom_home_sidebar_layout' );
function bk_custom_home_sidebar_layout( $layout )
{
// If we are on the home page, set the sidebar
if ( is_home() )
return 'no-sidebar';

// Or else, set the regular layout
return $layout;

}

Then I set up a header element to include content below the primary and above the blog post excerpts.

Perfect. Just what I wanted.

I love GP and will use it on as many projects as I can.

Bud

Hi Bud,

that sounds great. Glad you found the solution.
You may want to investigate the Layout Element - which provides the same controls you have applied with the PHP.

https://docs.generatepress.com/article/layout-element-overview/

Unlike the Layout and Disable Elements meta in the post editor, which does not work on a blog or archive because WP ignores them, this does.

This archived topic is closed to new replies.