我对按自定义字段筛选帖子有问题。在我的页面上,我有一个包含15个条件(放射性核素和输入)的表单,我想用它们过滤我的自定义post-type项目。我的问题是,当我使用这么多元键时,查询速度非常慢。这是我的代码:
$posts = get_posts(array(
\'numberposts\' => -1,
\'post_type\' => \'projekt\',
\'post_status\' => \'publish\',
\'s\' => $s,
\'meta_query\' =>
array(
\'relation\' => \'AND\',
array(
\'key\' => \'technologia_wyszukiwarka\',
\'value\' => $techs,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'zabudowa_wyszukiwarka\',
\'value\' => $styls,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'garaz_wyszukiwarka\',
\'value\' => $garazs,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'mdm_wyszukiwarka\',
\'value\' => $mdms,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'powierzchnia_wyszukiwarka\',
\'value\' => $pows,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'kondygnacja_wyszukiwarka\',
\'value\' => $konds,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'ogrzewanie_wyszukiwarka\',
\'value\' => $ogrzewanies,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'liczba_pokoi_wyszukiwarka\',
\'value\' => $pokojes,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'inne_wyszukiwarka\',
\'value\' => $innes,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'kat_dachu_wyszukiwarka\',
\'value\' => array($katods,$katdos),
\'compare\' => \'BETWEEN\',
\'type\' => \'NUMERIC\'
),
),
));
我的查询时间
WP_Query->get_posts
大约是10秒。但当我删除最后的条件时
kat_dachu_wyszukiwarka
时间更短,可以接受0.5秒,我用查询监视器进行了检查。不幸的是,我需要这个字段和几个字段。因此,我的问题是如何更快地执行查询?