繁体   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