I am trying to get all subcategories which have articles linked to it.
To visualize the needed result:
So for my pods , I have the following: (all Advanced Content Type)
Category pod :
Article pod :
I have this query, which works, but it does not skip the subcategories who has no articles in it.
$subcategories = pods( 'category',
array( 'where' => "category_relation.slug = 'Top Category"
) );
I know I should do a left join, but I do not see how to get that working because I can only select one pod type at once.
Have anyone experience with this type of getting pods data?
Note: I asked this question on the Pods forum too, but did not get any response. On SO I will reach more people I think and update the forum post on Pods.io with the best answer.
Have you tried 'where' => 'category_relation.slug = "Top Category" AND 0 < tt.count'
yet?
Also, if you pass any string into the 'where' that's a $variable, definite be sure to sanitize it first ( pods_sanitize( $variable )
, $wpdp->prepare( "category_relation.slug = %s", $variable )
, etc..)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.