WordPress循环中的随机顺序?

use*_*715 4 php wordpress loops

我在分类存档(艺术家)中使用基本循环代码,我想知道如何设置循环以随机顺序显示帖子('orderby'=>'rand')它似乎不起作用我添加数组?任何帮助都会很棒!

        <?php
                // Start the Loop.
                while ( have_posts() ) : the_post();

                    /*
                     * Include the post format-specific template for the content. If you want to
                     * use this in a child theme, then include a file called called content-___.php
                     * (where ___ is the post format) and that will be used instead.
                     */
                    array ( 'orderby' => 'RAND' );
                    get_template_part( 'content', get_post_format() );

                endwhile;
                // Previous/next page navigation.
                twentyfourteen_paging_nav();

            else :
                // If no content, include the "No posts found" template.
                get_template_part( 'content', 'none' );

            endif;
        ?>
Run Code Online (Sandbox Code Playgroud)

rav*_*tel 7

 <?php  

$query = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => '-1' ) );

        if( $query->have_posts() ):
                // Start the Loop.
                while ( $query->have_posts() ) : $query->the_post();

                    /*
                     * Include the post format-specific template for the content. If you want to
                     * use this in a child theme, then include a file called called content-___.php
                     * (where ___ is the post format) and that will be used instead.
                     */

                    get_template_part( 'content', get_post_format() );

                endwhile;
                // Previous/next page navigation.
                twentyfourteen_paging_nav();

            else :
                // If no content, include the "No posts found" template.
                get_template_part( 'content', 'none' );

            endif;
        ?>
Run Code Online (Sandbox Code Playgroud)

更多查询信息