WordPress.org

Ready to get started?Download WordPress

Forums

How to combine this query_post (6 posts)

  1. americo83
    Member
    Posted 3 years ago #

    Hello everybody. I would like include this query post in my wordpress:

    <?php
    if ( is_home() ) {
    query_posts( 'cat=-1,-3,-4,-5,-6,-7,-8' );
    }
    ?>

    also with this string: posts_per_page=3

    How can I do?

    Thank you.

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    <?php
    if ( is_home()) {
    query_posts( array (
         'posts_per_page' => 3,
         'cat' => '-1,-3,-4,-5,-6,-7,-8',
         'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
    ))
    }

    that last 'paged' line is necessary if you need pagination

  3. americo83
    Member
    Posted 3 years ago #

    Thanks Voodoo, but your code gives me an Internal Server Error 500. Why?

    I added ?> at the end of your code.

  4. americo83
    Member
    Posted 3 years ago #

    Ah it's ok. Missing ";" at the end :)

    Thanks Voodoo

  5. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    Oh yeah, sorry about that, I copied/pasted from my theme and missed the tail end of it

  6. americo83
    Member
    Posted 3 years ago #

    No problem, thanks :)

Topic Closed

This topic has been closed to new replies.

About this Topic