次のようないくつかの条件に基づいて、さまざまな値を配列に格納しようとしています。
<?php $sort= $_GET['sort'];
if($sort == "title") { $args = array('orderby'=>'title','order'=>'ASC'); }
elseif($sort == "date") { $args = array('orderby'=>'date'); }
else{ $args = array('orderby'=>'date','order'=>'DESC'); }
?>
そして、次$args
のように WP_Query を使用して wordpress ループに変数を挿入しようとしています:
<?php $loop = new WP_Query( array( $args, 'post_type' => 'films', 'post_parent' => 0, 'posts_per_page' => -1 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
wordpress loop stuff, and the end while, end if
これは正しく機能していません。配列を wordpress ループに間違って渡していますか?