Wordpress - 按分类过滤

发布于 2024-11-28 02:29:26 字数 751 浏览 2 评论 0原文

我的查询中发生了一些奇怪的事情,看不出出了什么问题 我从选择列表中传递变量 THEME 。 主题是从分类法主题中提取的,

所以我的代码看起来像

$thetheme = $_GET['theme'];`

$thetheme 是从 URL 正确传递的

,然后

$args2 = array(
     'tax_query' => array(
     array(
         'taxonomy' => 'theme',
         'field' => 'slug',
         'terms' => $thetheme
         )
     ),
     'post_type' => array( 'post', 'dvd' ), 
     'cat' => '31',
     'paged' => $paged, 
     'posts_per_page' => $listitems,
     'order' => 'DESC',
     'orderby' => 'date', 
     'query' => $wp_query
);`

查询仅适用于某些帖子,而不是所有帖子,并且无法理解为什么。 例如,如果我选择主题为“冒险”的帖子,它将提取正确数量的帖子。 但同一类别中不同主题的其他帖子将不会显示。

这让我很困惑......

帮助!

谢谢

Something weird happening in my query and can't see what's wrong
I am passing the variable THEME from a select list.
THe theme is pulled from the taxonomy THEME

so my code looks like

$thetheme = $_GET['theme'];`

$thetheme is correctly passed from URL

then

$args2 = array(
     'tax_query' => array(
     array(
         'taxonomy' => 'theme',
         'field' => 'slug',
         'terms' => $thetheme
         )
     ),
     'post_type' => array( 'post', 'dvd' ), 
     'cat' => '31',
     'paged' => $paged, 
     'posts_per_page' => $listitems,
     'order' => 'DESC',
     'orderby' => 'date', 
     'query' => $wp_query
);`

The query is working only on some Post, not all of them, and cant understand why.
If I select a post with the Theme "Adventure" for example, it will pull the correct amount of post.
But an other post, in the same category with a different theme, will not be displayed.

This is puzzling me....

HElP!

thx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画尸师 2024-12-05 02:29:26

我认为您不需要在这里运行完整的分类查询...尝试这个 =)

 $args2 = array(
      'theme' => $thetheme,
      'post_type' => array( 'post', 'dvd' ), 
      'cat' => '31',
      'paged' => $paged, 
      'posts_per_page' => $listitems,
      'order' => 'DESC',
      'orderby' => 'date', 
      'query' => $wp_query
 );

Don't think you need here to run complete taxonomy query... try this =)

 $args2 = array(
      'theme' => $thetheme,
      'post_type' => array( 'post', 'dvd' ), 
      'cat' => '31',
      'paged' => $paged, 
      'posts_per_page' => $listitems,
      'order' => 'DESC',
      'orderby' => 'date', 
      'query' => $wp_query
 );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文