Skip to main content
added 4 characters in body
Source Link
Aftab
  • 1.4k
  • 9
  • 19

According to what I understand is :

In your taxonomy.php

Add this code :

 $term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') );
 echo '<h2>Showing posts with topic : ' . $term->name<>name .'</h2>;h2>';

This will result in showing "Showing post with topic : Cancer"

Now for (all posts tagged with cancer already display here...)

You can run a get_posts() to get this :

$all_post = get_posts(array(
    'post_type' => array( 'cpt1', 'cpt2', 'cpt3', 'post' ), // all cpt slug name
    'numberposts' => -1, // number of post
    'tax_query' => array(
         array(
             'taxonomy' => get_query_var( 'taxonomy '), // current tax name
             'field' => 'id',
             'terms' => $term->term_id, // current tax_id
        )
    )
);

By looping over them we can get all post details and we can display them.

According to what I understand is :

In your taxonomy.php

Add this code :

 $term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') );
 echo '<h2>Showing posts with topic : ' . $term->name</h2>;

This will result in showing "Showing post with topic : Cancer"

Now for (all posts tagged with cancer already display here...)

You can run a get_posts() to get this :

$all_post = get_posts(array(
    'post_type' => array( 'cpt1', 'cpt2', 'cpt3', 'post' ), // all cpt slug name
    'numberposts' => -1, // number of post
    'tax_query' => array(
         array(
             'taxonomy' => get_query_var( 'taxonomy '), // current tax name
             'field' => 'id',
             'terms' => $term->term_id, // current tax_id
        )
    )
);

By looping over them we can get all post details and we can display them.

According to what I understand is :

In your taxonomy.php

Add this code :

 $term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') );
 echo '<h2>Showing posts with topic : ' . $term->name .'</h2>';

This will result in showing "Showing post with topic : Cancer"

Now for (all posts tagged with cancer already display here...)

You can run a get_posts() to get this :

$all_post = get_posts(array(
    'post_type' => array( 'cpt1', 'cpt2', 'cpt3', 'post' ), // all cpt slug name
    'numberposts' => -1, // number of post
    'tax_query' => array(
         array(
             'taxonomy' => get_query_var( 'taxonomy '), // current tax name
             'field' => 'id',
             'terms' => $term->term_id, // current tax_id
        )
    )
);

By looping over them we can get all post details and we can display them.

Source Link
Aftab
  • 1.4k
  • 9
  • 19

According to what I understand is :

In your taxonomy.php

Add this code :

 $term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') );
 echo '<h2>Showing posts with topic : ' . $term->name</h2>;

This will result in showing "Showing post with topic : Cancer"

Now for (all posts tagged with cancer already display here...)

You can run a get_posts() to get this :

$all_post = get_posts(array(
    'post_type' => array( 'cpt1', 'cpt2', 'cpt3', 'post' ), // all cpt slug name
    'numberposts' => -1, // number of post
    'tax_query' => array(
         array(
             'taxonomy' => get_query_var( 'taxonomy '), // current tax name
             'field' => 'id',
             'terms' => $term->term_id, // current tax_id
        )
    )
);

By looping over them we can get all post details and we can display them.