Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Atahualpa 3 Wordpress theme (http://forum.bytesforall.com/forumdisplay.php?f=2)
-   -   Varying number of posts on homepage, archive pages (http://forum.bytesforall.com/showthread.php?t=23355)

redacter Dec 11, 2015 11:06 PM

Varying number of posts on homepage, archive pages
 
I would like to have a different number of posts displaying on my homepage vs. my archive pages. For example, I only want one post to display on my homepage, but I would like 15 posts to display on category, tag, author pages, etc. This is the code I'm using, in the functions.php file, but it doesn't seem to work.

Any corrections, suggestions, improvements would be greatly appreciated. See the code below:

function number_of_posts_on_archive($query){
if ($query->is_archive) {
$query->set('posts_per_page', 15);
}
return $query;
}

add_filter('pre_get_posts', 'number_of_posts_on_archive');

BTW: my site is www.theimproper.com

Thanks in advance for your assistance.

Keith

juggledad Dec 12, 2015 04:20 AM

Your code works fine for me.

What do you have set at dashboard->settings->reading->Blog pages show at most? it should be 1

redacter Dec 12, 2015 07:51 AM

Thanks for your help!

I tried lowered the reading setting to 1 and still no luck. Does the code need to go in a specific place in functions.php? I just kind of put it in randomly... but now that I think about it, that may be the problem.

juggledad Dec 12, 2015 12:18 PM

This is a case where it would make sense to make a child theme so you can add it to the child themes function.php.

If you don't know how to make a child theme, do a google search becasue there are better writeups than I could make.


All times are GMT -6. The time now is 04:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.