我的一个页面上有以下代码。当我使用
echo get_num_queries()
. 我正在尝试减少查询量,但我无法找到它们的来源。
我唯一能想到的是get_post_meta
. get_post_meta 是否每次都运行查询?如果是这样,有没有更好的方法来做到这一点,所以我不会每次都运行查询?
<?php
/* This is the second wordpress loop which will show only non paid dealers per the above wp_query in query_single. The 0 passed is non-paid dealers*/
query_single('dealers', 'draft', '0', $taxtype, $value);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$address=get_post_meta($post->ID, 'wpcf-street_address', TRUE);
$city=get_post_meta($post->ID, 'wpcf-city', TRUE);
$state=get_post_meta($post->ID, 'wpcf-state_abbreviation', TRUE);
$zip=get_post_meta($post->ID, 'wpcf-zip_code', TRUE);
$phone=get_post_meta($post->ID, 'wpcf-phone_number', TRUE);
$paid=get_post_meta($post->ID, 'wpcf-paid', TRUE);
$post_id=get_the_ID();
get_each_dealer_brand($post_id);?>
<ul class="ullisting">
<?php
if($paid==0) {
echo "<li><p class=\"plisting\"><strong>";the_title();echo "</strong></p></li>";
echo "<li><p class=\"plisting\">$address | $city, $state $zip</p></li>";
echo "<li><p class=\"plisting\">P: $phone</p></li>";
echo "<li><p class=\"listing\"><span><small>$brands_list</small></span></p></li>";
}
?>
</ul>