Wordpress post in blog + post in home page

Linkebel
161 Posts
Linkebel posted this 08 October 2015

Hello,

I have a wordpress site in which I create a blog page and the home page, I wish there was the last 4 posts in home page.

The concern is that when I active the blog page (SETTINGS => Reading => static page) on the home page, the post are no longer displayed but the pages.

How to put the posts on the home page AND on the blog page ?

Thank you !

Hello, I have a wordpress site in which I create a blog page and the home page, I wish there was the last 4 posts in home page. The concern is that when I active the blog page (SETTINGS => Reading => static page) on the home page, the post are no longer displayed but the pages. How to put the posts on the home page AND on the blog page ? Thank you !
Vote to pay developers attention to this features or issue.
13 Comments
Order By: Standard | Newest
Stagger Lee
1818 Posts
Stagger Lee posted this 08 October 2015

So you struggle with typical WordPress scenario where settings of number of posts listed influence your homepage too ?

if it is so activate again posts for home, instead of static page, and use in Settings tab:

function surfaramachild_home_pagesize( $query ) {
    if ( is_admin() || ! $query->is_main_query() )
        return;


    if ( is_home() ) {
        // Display 5 post for the original blog archive
        $query->set( 'posts_per_page', 4 );
        return;
    }
}
add_action( 'pre_get_posts', 'surfaramachild_home_pagesize', 1 );

So you struggle with typical WordPress scenario where settings of number of posts listed influence your homepage too ? if it is so activate again posts for home, instead of static page, and use in Settings tab: function surfaramachild_home_pagesize( $query ) { if ( is_admin() || ! $query->is_main_query() ) return; if ( is_home() ) { // Display 5 post for the original blog archive $query->set( 'posts_per_page', 4 ); return; } } add_action( 'pre_get_posts', 'surfaramachild_home_pagesize', 1 );
Linkebel
161 Posts
Linkebel posted this 08 October 2015

Thanks for the reply

But I did not understand

I leave static page and I add this code in the settings tab => CMS code

When I did this nothing happens and if I add the <?php?> have a error message telling me to contact the team themler

Can you please describe to me the demarche to follow?

Thanks for the reply But I did not understand I leave static page and I add this code in the settings tab => CMS code When I did this nothing happens and if I add the &lt;?php?&gt; have a error message telling me to contact the team themler Can you please describe to me the demarche to follow?
Stagger Lee
1818 Posts
Stagger Lee posted this 08 October 2015

Dont ad php tags.

And it wont work with static page. Change to post list in WP settings.

Dont ad php tags. And it wont work with static page. Change to post list in WP settings.
Linkebel
161 Posts
Linkebel posted this 08 October 2015

Ok, I remove static page and I put the code in setting => cms code

Now how am I then to have the blog page?

PS: Thank you for taking the time to answer me

Ok, I remove static page and I put the code in setting => cms code Now how am I then to have the blog page? PS: Thank you for taking the time to answer me
Stagger Lee
1818 Posts
Stagger Lee posted this 08 October 2015

It comes automatically if you have not removed Post content control from home template.

It comes automatically if you have not removed Post content control from home template.
Linkebel
161 Posts
Linkebel posted this 08 October 2015

Unfortunately these explanations are not clear

Could you put the different steps to achieve please?

Unfortunately these explanations are not clear Could you put the different steps to achieve please?
Stagger Lee
1818 Posts
Stagger Lee posted this 08 October 2015

Settings - Reading - enable Your latest posts. Use this code above. If it doesnt work use this one:

function five_posts_on_homepage( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'posts_per_page', 4 );
    }
}
add_action( 'pre_get_posts', 'five_posts_on_homepage' );

Settings - Reading - enable Your latest posts. Use this code above. If it doesnt work use this one: function five_posts_on_homepage( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'posts_per_page', 4 ); } } add_action( 'pre_get_posts', 'five_posts_on_homepage' );
Linkebel
161 Posts
Linkebel posted this 09 October 2015

Ok I put settings => reading => enable your latest post
I put the code in themler => settings => cms code

And how have I done to my blog page?

;-)

Ok I put settings => reading => enable your latest post I put the code in themler => settings => cms code **And how have I done to my blog page?** ;-)
Stagger Lee
1818 Posts
Stagger Lee posted this 09 October 2015

What about "Blog" ?
It is just a word, nothing else. Why do you need it ?
I dont use "Blog" template on any of my webistes, not needed. Dont bother with it, you are limited to just one template. Make your own custom templates for all archive pages.

What about "Blog" ? It is just a word, nothing else. Why do you need it ? I dont use "Blog" template on any of my webistes, not needed. Dont bother with it, you are limited to just one template. Make your own custom templates for all archive pages.
Linkebel
161 Posts
Linkebel posted this 09 October 2015

Listen you is nice but if you do not know answer my question does not do.
For the purpose of a client I need to have on the home page the last 4 posts + a page where you can see all posts.

If you can tell me and if you do not know let somebody else answer.

Thanks

Listen you is nice but if you do not know answer my question does not do. For the purpose of a client I need to have on the home page the last 4 posts + a page where you can see all posts. If you can tell me and if you do not know let somebody else answer. Thanks
sunhome
8 Posts
sunhome posted this 11 October 2015

Try widgets. I am not at computer but I noticed that you can insert a widget area in Themler. Then in the wordpress admin, you should have access to that area via widgets.

Try widgets. I am not at computer but I noticed that you can insert a widget area in Themler. Then in the wordpress admin, you should have access to that area via widgets.
Linkebel
161 Posts
Linkebel posted this 13 October 2015

Which is annoying with widgets is that you can not customize like a post

Therefore I duplicate the model of the home page that I call blog and in wordpress I choose the blog page template for blog page

PS: Stagger Lee => When not know answer a question do not answer

Which is annoying with widgets is that you can not customize like a post Therefore I duplicate the model of the home page that I call blog and in wordpress I choose the blog page template for blog page PS: Stagger Lee => When not know answer a question do not answer

Last edited 13 October 2015 by Linkebel

grwaterman
5 Posts
grwaterman posted this 15 April 2016

Dude, you saved my life..... and I feel dumb now though.

Dude, you saved my life..... and I feel dumb now though.
You must log in or register to leave comments