I've added a custom taxonomy called "materia" in my single product page. For instance: https://www.editorialufv.es/catalogo/universitarios-socialmente-responsables/

When you click on one of the items of this taxonomy you're redirected to a new page with all the products that have that same item. For instance clikking on materia>item "arquitectura" you're redirected to this page: https://www.editorialufv.es/materia/arquitectura/

The problem is that the header of this page is the title of the last book added below that item. I'd like that the header would display the title of the item selected. In this case "arquitectura". How could I do that?

Adding the following code to the header-title.php file I've got the slug of the taxonomy:

$page_title = esc_html__(get_query_var( 'term' ),'materia');

How could I get the title of the taxonomy itslef and not the slug?

  • Cannot reproduce. For me, the title there is Arquitectura (AM) archivos - Editorial UFV. Generally, since you're using Yoast, you can define the title in Yoast's settings. – janh Dec 26 '17 at 12:51

You need to change the code that currently displays that header, so that it doesn't display the default title when it's on this taxonomy.

You can detect if you are on a taxonomy page with the is_tax() function, and then you could do something like this:

$term_array = get_term_by( 'slug', get_query_var( 'term' ), 'materia' );
                echo $term_array->name;
  • I mean $term_array->name – D. Dan Dec 27 '17 at 9:38

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.