• hello,

    can we add second taxonomy name inside page template ?

    for example i have a php file that contains

    <?php echo '<h1>' . single_term_title( "", false ) . '</h1>'; ?>

    to show the “Type” taxonomy terms title inside it’s pages.

    for example for this url: domain.com/tracks/type/music/

    it shows “music” as H1 in page.

    but for this url

    domain.com/tracks/type/music/artist/test1/

    it shows “Music” as H1 too.

    is there any way i can change H1 on this url to something like : “Music: Test1” ?

    (Music: a term of “type” taxonomy and test1 a term of “artist” taxonomy).

    can i detect the page url has two taxonomy and get each taxonomy terms name in php ? or any other way ?

    i’ll appreciate any hint

    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter Erfan MHDi

    (@erfanmhd)

    i’m not sure but maybe inside product_type taxonomy term php file
    i need to detect if this page is opened DIRECTLY via a link like this :
    domain.com/tracks/type/music/
    or a link like this :
    domain.com/tracks/type/music/artist/test1/
    and if there is another taxonomy inside url like artist
    i need to get info about artist term too like term name or term url so i can have a “Back to artist page link” too.

    something like this one maybe …

    if (get_queried_object() contains second taxonomy in url ) {
    	// like this url domain.com/tracks/type/music/artist/test1/ 
    	echo second_taxonomy_term->name;
    	echo second_taxonomy_term->link;
            show posts from type "music" and artist "test1"...;
    } else {
    	// like this url domain.com/tracks/type/music/ 
    	show posts from Music term of product_type taxonomy
    
    }

    i’m really struggling with these so hard :-))
    i know i’m not obviously an expert but is it possible the way i think at all ?
    i really appreciate your help if you got time,
    if not please clearify this for me, give me some hint so i get search for it maybe i can figure it out. ??

    Thanks.

    • This reply was modified 3 years, 12 months ago by Erfan MHDi.
    • This reply was modified 3 years, 12 months ago by Erfan MHDi.
Viewing 1 replies (of 1 total)
  • The topic ‘get second taxonomy term name inside php file’ is closed to new replies.