2015-12-14 68 views
0

我有一個文件名:taxonomy-product_cat-ford.php致命錯誤:調用未定義功能get_query_var()

在我的主頁我有一個菜單: All car | ford | toyota 默認我的主頁送花兒給人秀全車,我寫這個jQuery:

$('ul#main-car li a').click(function(){ 
    $('#content-car').load('<?php bloginfo('template_url');?>/content/taxonomy-product_cat-ford.php'); 
    return false; 
}); 

加載taxonomy-product_cat-ford.php文件,我已經查詢到調用products.But當我click鏈接項目:福特,這表明我:

Fatal error: Call to undefined function get_query_var() in .......

這裏是我的代碼:

<?php 
     $args = array(
     'post_type' => array('product'), 
     'tax_query' => array(
      'relation' => 'AND', 
      array(
       'taxonomy' => 'product_cat', 
       'field'  => 'slug', 
       'terms'  => array('ford'), 
       'operator' => 'IN', 
      ), 
     ), 
     'post_status' => 'publish', 
     'order' => 'DESC', 
     'orderby' => 'date', 
     'posts_per_page' => 12, 
     'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1, 
    ); 

     // WP_Query 
     $eq_query = new WP_Query($args); 
     $offset = 0; 
     $eq_total_posts = $eq_query->found_posts - $offset; 
     if ($eq_query->have_posts()) : 
     $eq_count = $args['paged'] * $args['posts_per_page'] - $args['posts_per_page']; 
     ?> 
     <?php 
     while ($eq_query->have_posts()): $eq_query->the_post(); 
     ?> 

     <?php woocommerce_product_subcategories(); ?> 
     <?php wc_get_template_part('content', 'product'); ?> 
    <?php 
     endwhile;endif; 
     wp_reset_query(); 
    ?> 
+1

它看起來像你沒有包括任何wordpress的文件...所以沒有WordPress的功能將可用。 – Jon

+0

Tks爲您提供幫助,像魅力^ _ ^一樣工作。 – DNS

回答

0

您還沒有包括WordPress的配套功能到腳本,儘量沿

require_once('wp-config.php'); 

(道路線的東西從你的腳本WP-配置可能會有所不同)

相關問題