Widget Area Assignment: Custom
-
Topic
-
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.
Tagged: widget areas custom
Hi Jason,
(FYI: I’m using Custom Post Type UI plugin to create custom post types and taxonomies)
Trying to assign sidebar widget areas to display on custom_post_type posts.
Specifically, I have a custom post type called “video”, and a taxonomy called “style”. Then, there are two types of “style”; there’s Yoga (yoga) and Aerial Play & Fitness (aerial-play-fitness).
I want to use the Custom Widget Area Assignment to load different widget/sidebars for each of both of my taxonomies (yoga, and aerial-play-fitness).
I cant seem to get this right by using your guides (at bottom) as examples.
In plain english, my logics needed are:
1) load this widget area if the post_type is video AND if the taxonomy style equals yoga
2) load this widget area if the post_type is video AND if the taxonomy style equals aerial-play-fitness
WHEN I use this: “video” == get_post_type() it works to limit the sidebar to ONLY “video” posts.
But I can’t seem to further filter down to either my “aerial-play-fitness” or “yoga” ‘styles.’
I tried THESE and they don’t work quite right:
“video” == get_post_type() && is_tax(“yoga”)
“video” == get_post_type() && is_tax(“style”, “aerial-play-fitness”)
“video” == get_post_type() && is_tax(style, aerial-play-fitness)
I FEEL LIKE I’m close?
Your Examples:
is_home()
is_home() || is_single()
“book” == get_post_type() || is_tax(“author”)
Hi,
I don’t think this isn’t really specific to Jump Start, but you’re just confused on what the function is_tax()
does.
https://codex.wordpress.org/Function_Reference/is_tax
The is_tax()
function returns true when it’s an archive of a taxonomy. In your case, you’re on a single post and you’re trying to see if that post has a certain term of a certain taxonomy.
Instead, give has_term()
a try.
https://codex.wordpress.org/Function_Reference/has_term
"video" == get_post_type() && has_term( 'aerial-play-fitness', 'style' )
This is one of the most useful pages in the WordPress Codex:
Ahhh! Thank you.