我试图根据元值将自定义帖子排序为优先级level1、level2和level3。我在post meta中给出了一个下拉字段,作为特色帖子、标准帖子和基本帖子。我想将它们显示为顶部的特色帖子,然后是标准帖子,然后是基本帖子。我尝试了以下代码,但它没有按顺序对帖子进行排序。
非常感谢任何指导或建议!
这是我的代码:
Array(
\'name\' => __( \'Listing Type Options\', \'text-domain\' ),
\'id\' => \'lising_type_options\',
\'type\' => \'select\',
\'child_of\' => \'\',
\'options\' => array(
\'\' => \'Select Listing Type\',
\'1\' => \'Basic\',
\'2\' => \'Standard\',
\'3\' => \'Featured\',
),
\'desc\' => \'\'
),
if( isset( $lp_type ) && !empty( $lp_type ) ){
if( $lp_type == \'3\' ){
$lp_type = \'Featured\';
} elseif( $lp_type == \'2\' ){
$lp_type = \'Standard\';
} elseif( $lp_type == \'1\' ){
$lp_type = \'Basic\';
}
} else{
$lp_type = \'\';
}
以下是查询:
$args = array(
\'post_type\' => $type,
\'post_status\' => \'publish\',
\'posts_per_page\' => $postsonpage,
\'paged\' => $paged,
\'post__not_in\' =>$ad_campaignsIDS,
\'tax_query\' => $TxQuery,
// \'meta_key\' => $MtKey,
// \'orderby\' => $lporderby,
// \'order\' => $lporders,
\'order\' => \'DESC\',
\'orderby\' => \'meta_value\',
\'meta_query\' => array(
\'relation\' => \'OR\',
$MtKey,
array(
\'relation\' => \'OR\',
array(
\'key\' => \'lp_listingpro_options\',
\'value\' => \'lising_type_options\',
\'compare\' => \'LIKE\',
),
array(
\'key\' => \'lp_listingpro_options\',
\'value\' => \'lising_type_options\',
\'compare\' => \'NOT LIKE\',
),
),
),
);