这是我的密码。它从url获取变量。它非常慢,有时甚至不完整。如何改进它?
注意:大多数情况下,一些变量没有任何值。我想,如果我检查这个并从查询中删除它的数组,它会有所改进。
$value1 = $_GET[\'extra1\'];
$value2 = $_GET[\'extra2\'];
$value3 = $_GET[\'extra3\'];
$value4 = $_GET[\'extra4\'];
$value5 = $_GET[\'extra5\'];
$value6 = $_GET[\'extra6\'];
$value7 = $_GET[\'extra7\'];
$value8 = $_GET[\'extra8\'];
$value9 = $_GET[\'extra9\'];
$value10 = $_GET[\'extra10\'];
$args = array(
\'meta_query\' => array(
array(
\'key\' => extra1,
\'value\' => $value1,
\'compare\' => \'=\'
),
array(
\'key\' => extra2,
\'value\' => $value2,
\'compare\' => \'=\'
),
array(
\'key\' => extra3,
\'value\' => $value3,
\'compare\' => \'=\'
),
array(
\'key\' => extra4,
\'value\' => $value4,
\'compare\' => \'=\'
),
array(
\'key\' => extra5,
\'value\' => $value5,
\'compare\' => \'=\'
),
array(
\'key\' => extra6,
\'value\' => $value6,
\'compare\' => \'=\'
),
array(
\'key\' => extra7,
\'value\' => $value7,
\'compare\' => \'=\'
),
array(
\'key\' => extra8,
\'value\' => $value8,
\'compare\' => \'=\'
),
array(
\'key\' => extra9,
\'value\' => $value9,
\'compare\' => \'=\'
),
array(
\'key\' => extra10,
\'value\' => $value10,
\'compare\' => \'=\'
)
)
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
the_title();
endwhile;
endif;