Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme »

Varying number of posts on homepage, archive pages


  #1  
Old Dec 11, 2015, 11:06 PM
redacter
 
14 posts · Oct 2009
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

Last edited by juggledad; Dec 12, 2015 at 04:16 AM.
  #2  
Old Dec 12, 2015, 04:20 AM
juggledad's Avatar
juggledad
 
23,682 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
Your code works fine for me.

What do you have set at dashboard->settings->reading->Blog pages show at most? it should be 1
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Dec 12, 2015, 07:51 AM
redacter
 
14 posts · Oct 2009
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.
  #4  
Old Dec 12, 2015, 12:18 PM
juggledad's Avatar
juggledad
 
23,682 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Bookmarks

Tags
archive pages, display posts, homepage

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to show all posts for the month in archive but only X number in home MacMcClellan Center area post/pages 2 Feb 17, 2013 06:49 AM
No excerpts but entire posts on 1st of my blog's pages archive bigliettaio Excerpts, Read more, Pagination 0 Jun 11, 2011 03:35 PM
[SOLVED] Different number of posts on home and post pages jasonchamb New Versions, & Updating 2 May 10, 2011 12:13 PM
[SOLVED] How can I get more posts to show up on archive/category pages? cowgrrrl Excerpts, Read more, Pagination 6 Jun 26, 2010 11:10 AM
number of excerpts on homepage luc Excerpts, Read more, Pagination 3 Mar 4, 2009 08:38 AM


All times are GMT -6. The time now is 01:59 AM.


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