WordPress.org

Ready to get started?Download WordPress

Forums

home page contains every months posts, why? (12 posts)

  1. attals
    Member
    Posted 3 years ago #

    Every new post, regardless of month it is posted, ends up on the same home page? How would I separate them like this WordPress Blog,
    http://publicdomainblog.com/2010/07/ ?

  2. applesfaceman
    Member
    Posted 3 years ago #

    all posts go to the home page unless otherwise specified by your self in the settings of your wp.

    if you have posts from different months they will display as many as you have set, try going to Settings > Reading, and changing how many posts are displayed, maybe this is what youre looking for

  3. attals
    Member
    Posted 3 years ago #

    Thanks for the reply, tried it but it dosen't work, this seems to be a global setting since it also changes the archive posts. Example, June was only one post (my first), July was three and so far one for August and if you look at the link I posted above, that's how I would like it to work. Any ideas?

  4. Saildude
    Member
    Posted 3 years ago #

    Not sure if this is what you are looking for, but.

    Many Themes have an Archive Widget that can be configured to show just the months in the sidebar. Drag and drop.

    Dashboard >> Appearance >> Widgets

    One of my sites just lists, June, July, Aug as options on the sidebar - click on the month and you just get the Posts for that month.

  5. attals
    Member
    Posted 3 years ago #

    Thanks but that's not the problem. It seems all my posts are going on the home page, no matter which month. Can something be configured to only have the current month's posts on the home page, while the previous months go into the archive (which they do now)? The previous months automatically go into archive but are also apperaing on the home page?

  6. Mark / t31os
    Moderator
    Posted 3 years ago #

    Posts do not go anywhere, the home page is just an archive view over all posts.

    Archives are not places you send posts to, they are just different queries for posts, a category archive is a query that specificies a given category, a month archive designates the month, a year archive the year, and so on..

    If you want to set the home page to the current month only (just posts from this month), then really your current question should be...

    "How do i set the home page to display the current month's post only"..

    Current behaviour is normal (how every WordPress blog works, unless configured otherwise).

    Am i following you correctly?

  7. attals
    Member
    Posted 3 years ago #

    Yes, Since it is a default setting as you have described, then I agree, the question is "How do i set the home page to display the current month's post only".. If I change it as discussed, then that would that limit the content search engines find, correct? Or do they also see the archive pages? I would like to configure it and have only the current month displayed on the 'home' page.
    Thanks again for your help

  8. Mark / t31os
    Moderator
    Posted 3 years ago #

    Try this is your theme's functions.php file, after the opening <?php (top of the file) on a new line.

    add_filter('pre_get_posts','home_current_month');
    function home_current_month( $query ) {
    	if( is_home() )
    		$query->set('month',date('m'));
    	return $query;
    }
  9. attals
    Member
    Posted 3 years ago #

    Mark,
    Just got to it today, did a copy & paste but it didn't make a difference. Any other ideas?
    Thanks,
    Tony

  10. Mark / t31os
    Moderator
    Posted 3 years ago #

    Where did you place the code? Did you query your home page when testing? (it will only run when the home condition is met).

  11. attals
    Member
    Posted 3 years ago #

    Placed code in 'Theme functions':
    <?php
    add_filter('pre_get_posts','home_current_month');
    function home_current_month( $query ) {
    if( is_home() )
    $query->set('month',date('m'));
    return $query;
    }
    $art_config = parse_ini_file(TEMPLATEPATH."/config.ini", true);

    Checked Home page and still not working
    Thanks again,
    Tony

  12. Mark / t31os
    Moderator
    Posted 3 years ago #

    Made a slight mistake with the last code... update that to..

    add_filter('pre_get_posts','home_current_month');
    function home_current_month( $query ) {
    	if( is_home() )
    		$query->set('monthnum',date('m'));
    	return $query;
    }

    The change being replacing month with monthnum.. :)

Topic Closed

This topic has been closed to new replies.

About this Topic