• Niraj Chauhan

    (@nirajmchauhan)


    hey hi Michael,
    i want to display custom taxonomies on pages,
    how can i do that,
    i have changed your plugin code, if you remember me i am the same guy who wanted the terms above the post, post

    now i want it to be displayed on pages
    i have three custom taxonomies, courses, location & duration
    i have created three pages with these names,
    now i just want that all my courses named custom taxonomy terms should be displayed on courses page, i selected all my courses terms from the side option in the edit page, but then also it is not coming
    how can they be displayed

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Michael Fields

    (@mfields)

    If I am understanding you correctly, you are seeking to display multiple posts having a term of one of these taxonomies on a page. If so, this is the incorrect way to go about doing this.

    WordPress 3.0 allows you to query for all posts associated with a term in a given taxonomy. /?location=taco-palace would display all posts located at the Taco Palace. The permalink alternative would look like this: /location/taco-palace/. You can also create a taxonomy.php file to tweak the display of taxonomy archives.

    Please let me know if I have understood you correctly.

    Thread Starter Niraj Chauhan

    (@nirajmchauhan)

    hey i solved that, but i have another question,
    i have in total 3 custom taxonomies, with many terms in it
    for eg. i have custom taxonomy named as location, then i have MBA in USA as a term in it,
    in url when i type this
    https://www.domain.com/location/mba-in-usa
    then i get all the posts related to mba-in-usa,
    but now i want some description on mba-in-usa page, same for others, how can i do this,
    for this i had an idea, if in archive.php i write a condition
    if(page url=https://www.domain.com/location/mba-in-usa){
    echo description
    }

    but for this i am not getting a function to check the url, i tried clean_url but it seems not to work,
    can you give me some idea on this?

    Plugin Author Michael Fields

    (@mfields)

    Try something like this:

    if ( is_tax() || is_category() || is_tag() ) {
    	$term = $wp_query->get_queried_object();
    	$taxonomy = get_taxonomy( $term->taxonomy );
    	$taxonomy_name = '';
    
    	if ( isset( isset( $taxonomy->singular ) ) {
    		$taxonomy_name = $taxonomy->singular;
    	}
    	else if ( $taxonomy->label ) {
    		$taxonomy_name = $taxonomy->label;
    	}
    
    	print '<h1>' . $taxonomy_name . '</h1>';
    
    	if ( isset( $term->term_id ) && isset( $term->taxonomy ) ) {
    		print term_description( $term->term_id, $term->taxonomy );
    	}
    }
    Thread Starter Niraj Chauhan

    (@nirajmchauhan)

    in this where i have to write the description part????????

    Plugin Author Michael Fields

    (@mfields)

    It will use the description that you entered for the term in the administration panels

    Thread Starter Niraj Chauhan

    (@nirajmchauhan)

    no but i want myself to write for every country, like mba-in-usa, mba-in-uk etc,
    is there anything in that,
    by that time i ll also try the above one

    Thread Starter Niraj Chauhan

    (@nirajmchauhan)

    i am getting this error
    Parse error: syntax error, unexpected T_ISSET, expecting T_STRING or T_VARIABLE or ‘$’ in /home/managem3/public_html/mbas/wp-content/themes/cityguide/archive.php on line 17

    i am putting this code in archive.php

    Plugin Author Michael Fields

    (@mfields)

    no but i want myself to write for every country, like mba-in-usa, mba-in-uk etc,
    is there anything in that,
    by that time i ll also try the above one

    Oh, so I guess I did misunderstand you. Try this plugin instead.

    Thread Starter Niraj Chauhan

    (@nirajmchauhan)

    i think still you are not getting me,
    check this page

    https://mbas.in/location/mba-in-usa

    i want to type a custom message or description on the top of this page,
    and there are many pages
    for eg
    https://mbas.in/location/mba-in-uk
    https://mbas.in/location/mba-in-india
    https://mbas.in/location/mba-in-africa
    https://mbas.in/location/mba-in-china
    etc
    for that i have to write some if else condition, where if the page url is usa, then display this description else if the url of page is asia then display this description

    is some code like this???

    Plugin Author Michael Fields

    (@mfields)

    If you are set on using page templates for this, then you make a custom page template and code a conditional:

    if ( is_page( 'your-page-slug' ) )
       print 'My message';
    else if ( is_page( 'a-different-page' ) )
       print 'A different message';

    repeat as much as necessary…

    Multiple taxonomy queries are a part of WordPress 3.1 and are working rather well in the Beta version.

    3 Bookmarks about javascript:
    https://wordpress.mfields.org?topics=javascript

    2 Bookmarks from WP Hardcore:
    https://wordpress.mfields.org?source=wp-hardcore

    1 Bookmark about javascript from WP Hardcore:
    https://wordpress.mfields.org/?topics=javascript&source=wp-hardcore

    This is probably the best way to do this IMO… but 3.1 is still in Beta at the moment….

    Thread Starter Niraj Chauhan

    (@nirajmchauhan)

    hey i googled it to find the slug of the page,
    according to this page info the slug of this url
    https://mbas.in/location/mba-in-usa
    is ‘mba-in-usa’
    but still it is not working,
    the messages or the description is still not coming
    this code i tried,

    <?php
    		if ( is_page( 'mba-in-usa' ) )
    			print 'My message';
    		else if ( is_page( 'mba-in-uk' ) )
    			print 'A different message';
    		?>

    but still it is not working

    Plugin Author Michael Fields

    (@mfields)

    Put the following code in archive.php where you would like the description to be displayed:

    if ( is_tax( 'location' ) ) {
    	print term_description();
    }

    Edit each term of the location taxonomy adding a description for each one.

    1. mba-in-uk
    2. mba-in-india
    3. mba-in-africa
    4. mba-in-china

    You should now see the description displayed in your archive template.

    Thread Starter Niraj Chauhan

    (@nirajmchauhan)

    hey thanks this worked,
    one last question is it possible to put the terms of taxonomy into drop-down box?
    i mean to say
    location:drop-down box(all terms of location)

    and when a person selects it, it directs to the corresponding page,

    Plugin Author Michael Fields

    (@mfields)

    Thread Starter Niraj Chauhan

    (@nirajmchauhan)

    i tried this code,

    <?php
    wp_dropdown_categories( array(
    'taxonomy' => 'location'
    ) );
    ?>

    and the it is working but i want a button next to the dropdown list, that when a person hits that button, it redirects to the corresponding page,
    or when the user selects the item from drop-down box, it immediately redirects it,
    is this possible?

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘[Plugin: Taxonomy Terms List] display it on pages’ is closed to new replies.