Forums

[resolved] WP_Query Problems -- "orderby=rand" not working :/ (3 posts)

  1. DavidG2
    Member
    Posted 1 year ago #

    Just realized I posted this in the wrong forum, that's why I got no replies, hopefully this is the right one. So here we go...

    I'm having a bit of a problem with my WordPress coding, I'm trying to get posts randomly from a set of posts. The problem I'm having right now is the orderby=rand part of the query.

    <?php $week = date('W'); $year = date('Y');	$headline = new WP_Query( 'year=' . $year . '&w=' . $week  ); $headline->query('posts_per_page=5&orderby=rand&showposts=1&tags=featured+breaking+BreakingNews+breaking news+specials+special+announcements'); while ($headline->have_posts()) : $headline->the_post(); $do_not_duplicate = $post->ID; ?>

    When I execute the site with the rand string, the posts don't work. However when ordered by date, it's perfectly fine. I don't see anything that's wrong with the PHP code! Can anybody help?

  2. DavidG2
    Member
    Posted 1 year ago #

    oh wow, nvm got it myself.

  3. lefreak
    Member
    Posted 8 months ago #

    Would you mind sharing the solution next time you solve an issue? Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic