Site logo

[Support request] check whether on taxonomy page

Home Forums Support [Support request] check whether on taxonomy page

Home Forums Support check whether on taxonomy page

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #797490
    Marco

    Hello
    what hook do I need to use in order to be able to check whether I’m on a tag archive/taxonomy page – as I understand is_tax() should give me the answer but I don’t know where to put it in my custom functions file

    #797794
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    If you’re using our Hook Elements, you can choose your taxonomy in the Display Rules: https://docs.generatepress.com/article/hooks-element-overview/

    Otherwise, is_tax() is the right function to check. How you use it depends on what exactly you’re trying to do.

    #797941
    Marco

    Thanks Tom – I basically like to have a function where I can check if I’m currently on a taxonomy archive page – pre-get-post didn’t work.

    #798170
    Tom
    Lead Developer
    Lead Developer

    What does the function do if it detects you’re on a taxonomy page?

    #798223
    Marco

    let’s say I’m on a page like: http://localhost/cms/wp-vitus/tag/project-mgmt/ – a taxonomy page – in the right sidebar I’d like to show all the other post titles that also have the tag slug “project-mgmt” – kind of a contextual widget that is created/populated dynamically – I don’t whether it is even possible to dynamically ad a widget to the right sidebar – however first I need to figure out whether I’m on a taxonomy page or not.

    wp_head, pre_get_posts don’t seem to work when running is_tax()

    #798230
    Marco

    I might got a little closer – `is_tag()’ seems to do the trick to find out whether I’m on a tag page

    #798258
    Tom
    Lead Developer
    Lead Developer

    A plugin like this might be worth checking out: https://wordpress.org/plugins/content-aware-sidebars/

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.