get_POSTS()

    <div class="sbox">

        <h2>随机文章</h2>

        <?

            $args = array(

                'numberposts' => 1,

                'category' => 'wpstudy',

                'orderby' => 'rand'

            );

            $rand_posts = get_posts( $args );

        ?>

        <ul>

        <? foreach ( $rand_posts as $post ) {

         setup_postdata( $post ); ?>

         <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>

        <? } wp_reset_postdata(); ?>

        </ul>

    </div>

猜你喜欢

转载自blog.csdn.net/liu709127859/article/details/81430864
get