WordPress.org

Support

Support » Installation » How to change random posts

How to change random posts

  • I would like to change the Featured Articles 2 to random posts.

    Here is the original code

    <!– Featured Articles #2 –>
    <?php if (!$paged) : if ( ($featured2_cat = arras_get_option(‘featured_cat2’) ) !== ” && $featured2_cat != ‘-1’ ) : ?>
    <?php
    if ($featured2_cat == ‘-5’) $query2 = array(‘post__in’ => get_option(‘sticky_posts’), ‘showposts’ => arras_get_option(‘featured2_count’) );
    elseif ($featured2_cat == ‘0’) $query2 = ‘showposts=’ . arras_get_option(‘featured2_count’);
    else $query2 = ‘showposts=’ . arras_get_option(‘featured2_count’) . ‘&cat=’ . $featured2_cat;

    $q2 = new WP_Query( apply_filters(‘arras_featured2_query’, $query2) );
    arras_get_posts(‘featured2’, $q2);
    ?>
    <?php endif; endif; ?>

    <?php arras_above_index_news_post() ?>

    and here is the code that i found in the docx

    • <h2>A random selection of my writing</h2>
        <?php
        $rand_posts = get_posts(‘numberposts=5&orderby=rand’);
        foreach( $rand_posts as $post ) :
        ?>

      • “><?php the_title(); ?>
      • <?php endforeach; ?>

  • The topic ‘How to change random posts’ is closed to new replies.
Skip to toolbar