Widget Logic
custom post types and/or custom taxonomies (6 posts)

  1. smdever
    Posted 6 years ago #

    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?)


    Thanks so much for any help you can give me.

  2. alanft
    Plugin Author

    Posted 6 years ago #

    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



    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.

  3. smdever
    Posted 6 years ago #

    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:


    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!

  4. smdever
    Posted 5 years ago #

    Hi there, sorry to revisit this, but this string


    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

  5. jeneenj
    Posted 5 years ago #

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


  6. smdever
    Posted 5 years ago #

    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...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic