Forums

Showing posts from a specific category on an external webpage (2 posts)

  1. ramsydney
    Member
    Posted 2 years ago #

    Hi, I have set up a WordPress query on a number of pages on my website to show a specific number of posts [query_posts('showposts=5');] from a specific category [query_posts('cat=1');]. The problem is that it is not limiting the number of posts to 5, it is showing all posts within that category.

    Here are two examples:
    http://www.abandf.com.au/insurance/
    http://www.abandf.com.au/newzealand/index.php

    This is the code I am using:

    <?php
    // Include WordPress
    define('WP_USE_THEMES', false);
    require('../news/wp-load.php');
    query_posts('showposts=5');
    query_posts('cat=1');
    ?>

    I hope someone can point out where I am going wrong. Thanks in advance for any help provided.

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    query_posts('showposts=5');
    query_posts('cat=1');

    instead, try

    query_posts('cat=1&posts_per_page=5');

Topic Closed

This topic has been closed to new replies.

About this Topic