D8 Views + Taxonomy > Change page title

I’ve created a view to display products based on the taxonomy vocabulary Categories.
I followed a few how tos and check for answers on drupal.org, here & other websites but none is working.

I would like the title of the view to be the name of taxonomy term displayed.

The Path is : taxonomy/term/%
Contextual filter:
— When the filter value is NOT in the URL > Provide default value > Taxonomy Term ID from URL
— When the filter value IS in the URL or a default is provided > Specify validation criteria > Taxonomy Term ID
— — Vocabulary > Categories

To overwrite the title, I have 2 Replacement patterns available :

{{ arguments.field_categories_target_id }} == Product: Cat├ęgories (field_categories) title
{{ raw_arguments.field_categories_target_id }} == Product: Cat├ęgories (field_categories) input

The both display the Taxonomy term ID, not the name.

I’ve tried with other replacement patterns, nothing is displayed.

I’m running Drupal 8.9.13.

Thanks for your help!

8 – How can I show related terms in the same list with related nodes in taxonomy term page?

Views can’t show two different types of entities (terms + nodes) in the same view. This is the way Views works and cannot be changed.

Here’s what you can do instead.

Make two views, embed one in the other

In this approach, in your view, you can make two displays, one for nodes and one for terms. Make one of the displays of the “Embed” type. You can then add the “embed” display to the other view– in the header or footer area, choose to embed a view within a view, and then select your embed display.

Taxonomy term lookup during content migration is failing

I’m importing some data from a CSV file as nodes into my site. I’m having trouble with importing values into a entity reference field (which is a taxonomy term with multiple values).

Here’s just that field (not going to write the entire migrations file as everything else but that field works)

    - plugin: skip_on_empty
      source: "Audi, BMW, Citroen, Renault, Volvo"
      method: process
    - plugin: entity_lookup
      source: "Audi, BMW, Citroen, Renault, Volvo"
      value_key: name
      bundle_key: vid
      bundle: proposed_usage
      entity_type: taxonomy_term
      ignore_case: true
    - plugin: explode
      delimiter: ','
    - plugin: callback
      callable: trim

I’ve replaced the source file with the actual value for that field (so that it’s more clear).
The only error I get is that the migration failed.

Any help?

debug – Hot to display custom Taxonomy Dropdown Posts

I created a dropdown of my custom taxonomy, one is Categories and the second is Types, now everything is ok I guess but when I click on the dropdown list and select one of the sub-category, it displays nothing just a blank page…

function get_terms_dropdown_grade_level($taxonomies, $args){
$myterms = get_terms($taxonomies, $args);
$output =””; //I can change this name (for my remembreance)!
$output .=”Select Types”;
foreach($myterms as $term){
$root_url = get_bloginfo(‘url’);
$term_name =$term->name;
$link = $term_slug;
$output .=””.$term_name.””;
$output .=””;
return $output;

function get_terms_dropdown_type($taxonomies, $args){
        $myterms = get_terms($taxonomies, $args);
        $output ="<select name='Categories'>"; //I can change this name (for my remembreance)
        $output .="<option value=''>Select Categories</option>";              
    foreach($myterms as $term){
                $root_url = get_bloginfo('url');
                $term_name =$term->name;
                $link = $term_slug;
                $output .="<option value='".$link."'>".$term_name."</option>";
        $output .="</select>";
return $output;

And this is what I have on the post type sidebar page, I write this code into the sidebar.php file because I wanna show dropdown on all pages:

” method=”get”>

$select = get_terms_dropdown_grade_level($taxonomies, $args);
$select = preg_replace(“#)*)>#”, “”, $select);
echo $select;
$select = get_terms_dropdown_type($taxonomies, $args);

    $select = preg_replace("#<select((^>)*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
    echo $select;
    <input type="submit" name="submit" value="Go" />

How to display Custom Taxonomy as a dropdown list

I wanna display posts of 2 taxonomies when I click the taxonomy it will show sub-category as a dropdown list & when I click on any sub-category it will show posts, first is “Types” & the other is “Categories”, in these 2 taxonomies I put some posts and also in these taxonomies there are some sub-categories like, in first taxonomy “Type” I add these 4 sub-category; Science, Sports, Technology & World. In the second taxonomy “Categories” I add these 4 sub-category; General Knowledge, Machine Learning, History & Space.

function diwp_arts_custom_post_type(){

// here I am setting labels for custom post type

$labels = array(
                 'name' => 'Arts',
                 'singular_name' => 'Art',
                 'add_new'    => 'Add New Post',
                 'add_new_item' => 'Enter Art Details',
                 'all_items' => 'All Arts',
                 'featured_image' => 'Add Feature Image',
                 'set_featured_image' => 'Set Feature Image',
                 'remove_featured_image' => 'Remove Feature Image'


// here I am setting Options for custom post type

$args = array(    
                'public' => true,
                'label'       => 'Arts',
                'labels'      => $labels,
                'description' => '  Arts is a collection of all Art and their info',
                'menu_icon'      => 'dashicons-art',    
                'supports'   => array( 'title', 'editor', 'thumbnail'),
                'capability_type' => 'page',

register_post_type('arts', $args);

add_action( 'init', 'diwp_arts_custom_post_type' );

function wpdocs_create_book_tax() { register_taxonomy( 'Types', 'arts', array( 'label' => __( 'Types', 'textdomain' ), 'rewrite' => array( 'slug' => 'arts' ), 'hierarchical' => true, ) );

register_taxonomy( 'Categories', 'arts', array(
    'label'        => __( 'Categories', 'textdomain' ),
    'rewrite'      => array( 'slug' => 'arts' ),
    'hierarchical' => true,
) );

add_action( 'init', 'wpdocs_create_book_tax', 0 );

//Custom post type coding has been ended here

// Coding to create shortcode

function diwp_create_shortcode_arts_post_type( $atts ){

$atts = shortcode_atts( array(
    'type' => ' ',
), $atts );

$args = array(
                'post_type'      => 'arts',
                'posts_per_page' => '10',
                'post_status' => 'publish',
                'tax_query'     => array( array(
                            'taxonomy'  => 'Types',
                            'field'     => 'term_id',
                            'terms'     =>  wp_parse_id_list( $atts('type') ),
                        ) )

$query = new WP_Query($args);

if($query->have_posts()) :

    while($query->have_posts()) :

        $query->the_post() ;
    $result .= '<div class="art-item">';
    $result .= '<div class="art-image">' . get_the_post_thumbnail() . '</div>';
    $result .= '<div class="art-name">' . get_the_title() . '</div>';
    $result .= '<div class="art-desc">' . get_the_content() . '</div>';
    $result .= '</div>';




return $result;            

add_shortcode( 'arts-list', 'diwp_create_shortcode_arts_post_type' );

Restrict specific user for commenting if post has a specific taxonomy

today I tried a lot of things to fix this problem, I hope somebody can help me. I will explain my problem with example. : lets take i have a user named Maykl and I want to prevent Maykil to write comment for posts that have Movies kategory. This user can read comments but he must not write comment to this post. Warning ! I dont want to restrict user role. I want to restrict a specific user. How can I do this or is it possible in wordress? Thanks for your attention !

Is it possible to add the Gutenberg block editor to a custom taxonomy?

I have been trying to find a way to do it but I can’t get it to work. I have tried show_in_rest => 'true' which works for custom post types but not custom taxonomies. I also found an example on here to add this to my functions file but it didn’t work either.

function ux_portfolio_block_cat_editor( $args, $taxonomy ) {
    if ( 'my_taxonomy_name_here' === $taxonomy ) {
        $args('show_in_rest') = true;
    return $args;
add_filter( 'register_taxonomy_args', 'ux_portfolio_block_cat_editor', 20, 2 );

List auhtor by his custom post count in current taxonomy

I have multi author website. I am trying to show author list ordered by his total post count. I use custom taxonomies and two (2) post types : “news” and “movies”. In the list author name, avatar and post count will displayed. and author url will be author post archive page . Please help me

<?php function get_authors_with($num = 5){
    global $wpdb;
    $term_slug = get_query_var( 'term' );
    $taxonomyName = get_query_var( 'taxonomy' );
    $current_term = get_queried_object( 'slug', $term_slug, $taxonomyName );
    $sub_q = $wpdb->prepare("SELECT * FROM $wpdb->posts
            INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
            INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
            WHERE ($wpdb->term_taxonomy.term_id = %s
            AND $wpdb->term_taxonomy.taxonomy = '%s'
            AND $wpdb->posts.post_type = 'news,movies'
            AND $wpdb->posts.post_status = 'publish')",
    $sql = $wpdb->prepare("SELECT $wpdb->posts.post_author, FROM (%s)
            GROUP BY $wpdb->posts.post_author
            HAVING count(*) > %s",
    return $wpdb->get_results($sql);
} ?>

8 – How to filter content by a specific taxonomy term when vocabulary allows multiple values?

I have defined a vocabulary that allows multiple terms to be checked for a Content Type and I would like to create a View that could gather all the data from that Content Type but grouping the results by a specific term.

When I’m not applying any contextual filter, the result list should contain a group of data for every term in my vocabulary. Naturally, some of the items will appear in multiple groups because of the multiple terms scenario.

I would like to create a contextual filter for a specific term and get as a result only one of those groups. The problem is that I’m getting not only the group I expect but other groups in which some of the results have more than one term selected for the same vocabulary.

For example:

  • Content type is “Dogs”.
  • Vocabulary is “Places”.
  • Taxonomy terms for “Places” are: “Kitchen”, “Living room”, “Garage”, “Outside”.

“Dogs” has a field called “Places to play with my owner” which is related to “Places” and the user can select one or more options.

I created a view that has:

  • A relationship with “Places” vocabulary.
  • A contextual filter that retrieves all the “Dogs” that play on each of those places when there is no specific term to filter.
  • A field group using the “Places” term names.

And retrieves the following results on a URL like: /dogs/places-to-play/:

  • Kitchen: Dog A, Dog B.
  • Living Room: Dog A.
  • Garage: Dog C.
  • etc.

The contextual filter should receive a “Places” term name via URL like: /dogs/places-to-play/kitchen and the expected result would be:

But in my case, the results are:

  • Kitchen: Dog A, Dog B.
  • Living Room: Dog A.

Because “Dog A” has options “Kitchen” and “Living Room” selected in its “Places to play” field.

The question is: Is there a way to avoid getting the extra groups?

Thanks in advance.

Adding taxonomy term to a group

I am trying to add taxonomy terms to groups (using the group module). I need terms to filter groups within a view. But as a result, the exposed filters don’t seem to work. There is no error, but the behavior of filters is not expected. When I request the display of A-term groups and B-term groups (from two different vocabularies), the view displays nothing. It is not logic.
Question: is group module compatible with taxonomy core module ? I mean: is it possible to add taxonomy terms directly to groups (and not group contents) ?