• Hi there,

    Sorry if this has been asked before, I searched on the forum, but couldn’t find anything.

    I would like a widget to display on all archive pages for a custom post type and on all single posts of that custom post type.

    Since I have a taxonomy specified for that post type, this could also be achieved by specifying the taxonomy.

    Is there a way to do either of those?

    I saw the thread on Taxonomy woes and tried the following shortcodes that were suggested, but they didn’t work for me (perhaps I did something wrong?)

    is_post_type_hierarchical($post_type)
    is_post_type_hierarchical(‘book’)

    Thanks so much for any help you can give me.
    Sarawan

Viewing 5 replies - 1 through 5 (of 5 total)
  • is_post_type_hierarchical and co are just conditional values that apply to the blog as a whole – nothing to do with the individual post/page/view the client is looking at.

    but if you look a bit above that bit of the conditional tag page on the codex, there is

    http://codex.wordpress.org/Conditional_Tags#A_Post_Type

    get_post_type()==’book’

    try variations on that.

    is_single() && (get_post_type()==’book’)

    should work for single posts of that type. It’s not something I’ve experimented with myself. For ‘archive pages for a custom post type’ I’m not sure (I didn’t even know you could do that), but I hope that’s pointed you in the right direction.

    Thread Starter smdever

    (@smdever)

    Thanks so much for your help. I’ve ended up using your suggestion to get the single posts, and then am using is_tax for the archive pages. It may be inelegant, but at least it works for this particular case:

    is_tax(‘store’)||is_single()&&(get_post_type()==’listing’)

    You’re right, archive for custom post type is totally stupid, since it’s a taxonomy and taxonomies can be for different post types. I’m very new to this, as you can tell.

    Thanks again!

    Thread Starter smdever

    (@smdever)

    Hi there, sorry to revisit this, but this string

    is_single()&&(get_post_type()==’pv_listing’)

    was working fine for me until just recently when I realized that the appropriate widgets were no longer displaying on singular posts of that post type. Have not downloaded any weird plugins since, and Widget Logic is working as usual otherwise. Any ideas why this might be? I realize this may not be related to the plugin at all, but not sure where else to ask this question

    🙂 thanks

    is_single etc, etc. didn’t work for me, but this did:

    is_singular(‘custom_post_name_here’)

    Thread Starter smdever

    (@smdever)

    Hmm, none of these are working for me. I’ll keep digging to find out if it’s just a problem at my end or what…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Widget Logic] custom post types and/or custom taxonomies’ is closed to new replies.