问题的一部分是“caller\\u get\\u posts”不受欢迎,现在是“ignore\\u sticky\\u posts”。
主要问题是这行“$post\\u type=$wp->query\\u vars[“product”];”,我删除了这个,并用“product”替换了$post\\u类型。
此代码有效!
<?php
$tax = \'product_category\';
$tax_terms = get_terms($tax,\'hide_empty=0\');
if (is_array($tax_terms)) {
foreach ($tax_terms as $tax_term) {
$args=array(
\'post_type\' => \'product\',
"$tax" => $tax_term->slug,
\'post_status\' => \'publish\',
\'posts_per_page\' => -1,
\'ignore_sticky_posts\'=> 1
);
$my_query = new WP_Query($args);
if ( $my_query->have_posts() ) {
echo "<li><div>$tax_term->name</div>";
echo "<ul>";
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php $delta_article_number = get_post_meta( get_the_ID( ), \'delta_article_number\', true ); echo $delta_article_number; ?> <?php the_title(); ?></a></li>
<?php
endwhile;
echo "</ul></li>";
}
}
}
wp_reset_postdata(); wp_reset_query();
?>