Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress Query and Get_Post_Meta
    primarykey
    data
    text
    <p>I have the below code on one of my pages. This page is showing 100 queries when I use <code>echo get_num_queries()</code>. I am trying reduce the amount of queries but I am having trouble finding where they are all coming from. </p> <p>The only thing I could figure is the <code>get_post_meta</code>. Does get_post_meta run a query each time? If so is there a better way to do this so I don't run a query each time?</p> <pre><code>&lt;?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); ?&gt; &lt;?php if (have_posts()) : ?&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;?php $address=get_post_meta($post-&gt;ID, 'wpcf-street_address', TRUE); $city=get_post_meta($post-&gt;ID, 'wpcf-city', TRUE); $state=get_post_meta($post-&gt;ID, 'wpcf-state_abbreviation', TRUE); $zip=get_post_meta($post-&gt;ID, 'wpcf-zip_code', TRUE); $phone=get_post_meta($post-&gt;ID, 'wpcf-phone_number', TRUE); $paid=get_post_meta($post-&gt;ID, 'wpcf-paid', TRUE); $post_id=get_the_ID(); get_each_dealer_brand($post_id);?&gt; &lt;ul class="ullisting"&gt; &lt;?php if($paid==0) { echo "&lt;li&gt;&lt;p class=\"plisting\"&gt;&lt;strong&gt;";the_title();echo "&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;"; echo "&lt;li&gt;&lt;p class=\"plisting\"&gt;$address | $city, $state $zip&lt;/p&gt;&lt;/li&gt;"; echo "&lt;li&gt;&lt;p class=\"plisting\"&gt;P: $phone&lt;/p&gt;&lt;/li&gt;"; echo "&lt;li&gt;&lt;p class=\"listing\"&gt;&lt;span&gt;&lt;small&gt;$brands_list&lt;/small&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;"; } ?&gt; &lt;/ul&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload