0

How do I display the name of a taxonomy term page in a block?

For example, I am on the ww.example.com/taxonomy/term page and I want a title block on that page that displays TERM. Is there any PHP already written for this out there?

I tried a couple of suggestions made here using contextual filters but they do not work, either the block doesn't show or the term displayed is not the one in the URL (The taxonomy has children.)

Thanks. :)

1

I will answer my own question here:

  • Create a block view (taxonomy term)
  • Add relationship: "Taxonomy term: Content using your vocabulary)
  • Add contextual filter "Taxonomy term: Term ID" (no depth)

    Configure the filter to "Provide Default Value: Taxonomy term ID from URL" below,

    Check "Override title" and type "%1" in the input box

    Specify validation criteria: "Taxonomy Term"

    check box that has your vocabulary,

    Select the Filter value type: Term ID

That's it. No need to add fields or filters. You can remove all sorting criteria.

This works even if you have several levels of children. All it does is take the term of the vocabulary that is in your URL and displays it as the page title. Also works if the page or view, or whatever is there, is empty or returns no results.

Hope that helps. :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.