category post per page (3 posts)

  1. yortem
    Posted 2 years ago #

    im using this code for post per page

    add_filter('pre_get_posts', 'limit_category_posts');
    function limit_category_posts($query){
        if ($query->is_category) {
            $query->set('posts_per_page', 5);
        return $query;

    but it makes foreach in the header.php also to be 5 post per page.
    the foreach is like this :

    <?php $catPost = get_posts(array('category'=>get_cat_ID( 'news' ),'numberposts'=>2)); ?>
    <?php foreach ($catPost as $post) : setup_postdata($post); ?>
    content of post in the header
    <?php endforeach; ?>

    what can ido?
    i want to posts in the header will be only 2 and every page in the category will be 5..

    hope you will understand.

  2. Michael
    Forum Moderator
    Posted 2 years ago #

  3. Michael Beckwith
    Posted 2 years ago #

    delete my post here. posted to wrong thread.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.