• Check out EntertainmentCocktail.com/movies for the page that’s bothering me.

    As you can probably see, I’m trying to have a list of “Recent Film News” on the left underneath the recent reviews box. I’ve managed to include exclusively movie-category news, but for some reason it wont limit it to just 8 articles.

    My code for that section:

    <ul class="list2">
    
    <?php global $latestnews;
    
    $args = array(
        'numberposts'     => 5,
        'category'        => 3,
        'orderby'         => 'post_date',
        'order'           => 'DESC',
        'post_type'       => 'post',
        'post_status'     => 'publish' );
    
    $latestnews = get_posts($args);
    ?>
    
    <?php foreach ($latestnews as $post) : setup_postdata($post); { ?>
    
    	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    
    <?php } endforeach; ?> </ul>

    As you can see, I’ve made sure to use the numberposts tag in the array (set to 5 so I can clearly see a difference when it’s working!) but on the website it’s showing all 9 (current) articles.

    What’s going wrong?!

Viewing 8 replies - 1 through 8 (of 8 total)
  • $args = array(
        'posts_per_page'     => 5,
        'category'        => 3,
        'orderby'         => 'post_date',
        'order'           => 'DESC',
        'post_type'       => 'post',
        'post_status'     => 'publish' );
    Thread Starter magicwings

    (@magicwings)

    I’ve changed the source code but it still shows all 9 posts.

    Also for some reason now whenever I try to post/edit a post I receive a “404” error. This is driving me insane, but I’d rather just fix the page issues first and deal with the 404 issue later!

    global $latestnews;

    What’s that for? Try removing it.

    Thread Starter magicwings

    (@magicwings)

    This web page has a redirect loop
    The web page at http://www.entertainmentcocktail.com/wp-admin/edit.php has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
    Here are some suggestions:
    Reload this web page later.
    Learn more about this problem.
    Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

    This is getting worse and worse. Now I can’t access any of the admin pages or the dashboard.

    As this is a commercial theme, you really need to seek support from the theme vendors.
    Elegant Themes Support: http://www.elegantthemes.com/forum/

    Thread Starter magicwings

    (@magicwings)

    The theme’s working fine now, after a fresh WordPress installation.

    The page is now up at http://www.entertainmentcocktail.com/film.

    I still have the same problem as previously stated.

    Code:

    <ul class="list2">
    <?php
    $args = array('numberposts'=>5,'category'=>3, 'orderby'=>'post_date', 'order'=>'DESC', 'post_type'=>'post', 'post_status'=>'publish');
    $latestnews = get_posts($args);?>
    <?php foreach ($latestnews as $post) : setup_postdata($post); { ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php } endforeach; ?> </ul>

    As you can see on the page, it outputs ALL the posts in the category, despite what I change the 'numberposts' to.

    This isn’t affected by changing the variable to 'posts_per_page'.

    Is it a syntax problem or what?

    Thread Starter magicwings

    (@magicwings)

    Update: If I take out 'category'=>3 then it returns just 5 posts. Of course, they’re from all over the place, so it’s pretty useless.

    Why is it that the combination of category and numberposts doesn’t work?!

    Thread Starter magicwings

    (@magicwings)

    Using array AND get_posts() both result in retrieving ALL posts in the category despite the 'numberposts=5' condition.

    If I take out the category=3 then it retrieves just 5 posts (great) but they’re of course not from the category I’m after (bad).

    Why doesn’t this work, and is there a way around it?!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Outputting more posts than I want it to’ is closed to new replies.