簡體   English   中英

致命錯誤:調用未定義的函數get_query_var()

[英]Fatal error: Call to undefined function get_query_var()

我有一個文件名: taxonomy-product_cat-ford.php

在我的主頁上,我有一個菜單: All car | ford | toyota All car | ford | toyota 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文件。但是當我click鏈接項:ford時,它顯示了我:

致命錯誤:在.......中調用未定義的函數get_query_var()

這是我的代碼:

   <?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();
    ?>

您尚未在腳本中包含Wordpress支持功能,請嘗試以下方法:

require_once('wp-config.php');

(從腳本到wp-config的路徑可能會有所不同)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM