logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$5
display custom taxonomy tags OUTSIDE the loop


EDIT: The answer has been found here...
http://wordpress.org/support/topic/how-to-display-custom-taxonomy-tags-outside-the-loop?replies=2#post-3041465

$suburbs = get_terms('suburbs','hide-empty=0&orderby=id');
shuffle($suburbs);
foreach ( $suburbs as $suburb ) {
if( ++$count > 10 ) break;
echo "COUNT:$count ID:$suburb->term_id NAME:$suburb->name SLUG:$suburb->slug <br />";
}



I hope I can explain this correctly... the WordPress terminology with custom taxonomies is a bit confusing for for me...

I have a normal page with 100 custom tags assigned to it. These custom tags are assigned to the 'electrician'.

I have a template page called taxonomy-electrician.php

This template page simply shows the below, depending on the custom tag...

<?php single_tag_title(); ?>
is an electrician

In effect it makes me 100 different pages (1 for each custom tag)

I have another group of 50 custom tags from a different custom taxonomy (suburbs).
NB: This group of 50 tags are not related in any way way to the 100 'electrician' custom tags

On my taxonomy-electrician page I also want to show a list of 10 random custom tags from the other custom taxonomy (suburbs).

In effect I want the taxonomy-electrician.php page to look like this...

Bill is an electrician

[10 random tags from 'suburbs']


************************************
******* edit *************************
************************************

OK Basically I want to show this OUTSIDE the loop, that is, show this anywhere in any template file...
<?php 
wp_tag_cloud( array( 'taxonomy' => 'suburb', 'format' => 'flat', 'order' => 'rand', 'separator' => ', ','number' => 45, ) );
?>

pjeaje | 08/04/12 at 8:31am Edit
Tutorial: How to assign prize money

Previous versions of this question: 08/04/12 at 9:53am | 08/04/12 at 9:53am | 08/04/12 at 7:56pm | 08/04/12 at 8:16pm | 08/04/12 at 8:26pm

(2) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    08/04/12
    8:55am
    Arnav Joy says:

    see this url
    http://wordpress.org/support/topic/get-tags-specific-to-category

    • 08/04/12 9:01am

      pjeaje says:

      Thanks but i don't think it's what I'm asking for... maybe it's me not explaining it correctly? Categories really have nothing to to do with it... the focus is displaying the tags/terms from a custom taxonomy group anywhere in any theme file.

    • 08/04/12 9:03am

      Arnav Joy says:

      try the code there by replacing "category" to your taxonomy name "suburbs"

    • 08/04/12 9:03am

      pjeaje says:

      I need something like this... but I want to be able to have control over the number of tags displayed, the order (random) and how the tags are separated e.g. list, by comma etc.

      <?php
      $taxonomy = 'electrician';
      $queried_term = get_term_by( 'slug', get_query_var($taxonomy) );
      $terms = get_terms($taxonomy);
      if ($terms) {
      foreach($terms as $term) {
      echo '<li><a href="' . $term->slug . '">' . $term->name .'</a></li>';
      }
      }
      ?>

    • 08/04/12 9:09am

      pjeaje says:

      There's a variety of codes there... which one in particular are you inferring?

    • 08/04/12 9:11am

      Arnav Joy says:

      code by "john.andrews"

    • 08/04/12 9:15am

      pjeaje says:

      Do I replace EVERY instance of category' with 'taxonomy' ?

    • 08/04/12 9:18am

      pjeaje says:

      It would be nice if you could paste the code here with all the changes that need to be made. Thanks.

    • 08/04/12 10:39am

      Arnav Joy says:

      try this



      <?php

      wp_tag_cloud( array( 'taxonomy' => 'suburb', 'format' => 'list', 'order' => 'RAND', 'number' => 10, echo => 1 ) );

      ?>



    • 08/04/12 10:42am

      pjeaje says:

      That kills my theme :)

    • 08/04/12 10:44am

      Arnav Joy says:

      forgot to place a quote sign , here it is

      <?php



      wp_tag_cloud( array( 'taxonomy' => 'suburb', 'format' => 'list', 'order' => 'RAND', 'number' => 10, 'echo' => 1 ) );



      ?>

    • 08/04/12 10:47am

      pjeaje says:

      OK this is the same problem I've been getting for ages... for some reason it's just picking out 10 tags and randomising those same 10 tags each time the page refreshes... i need a completely new random set of 10 tags each time... this isn't happening ?????

    • 08/04/12 12:08pm

      pjeaje says:

      Any other ideas?

  • avatar
    Last edited:
    08/04/12
    10:00am
    Jatin Soni says:

    Here is the code I am using for my own template and works fine

    <?php // Let's get the data we need
    $term_category = get_the_term_list( $post->ID, 'your_cpt_category', '', ', ', '' );
    $term_tags = get_the_term_list( $post->ID, 'your_cpt_tags', '', ', ', '' );
    ?>


    and than echo the variable

    <?php echo $term_category; ?>
    <?php echo $term_tags; ?>


    This will surely render the taxonomy

    • 08/04/12 10:35am

      pjeaje says:

      Where do i insert these?

    • 08/04/12 10:38am

      pjeaje says:

      OK get it working but it's only half of what i need... I need apply arguments to it, namely randomise it, numberise it and separatise it...

    • 08/04/12 10:57am

      Jatin Soni says:

      Okay let me try with that too. I will post another code in few minutes.

    • 08/04/12 10:58am

      Jatin Soni says:

      Ah! sorry I missunderstood.....I still confuse what arguments you want on it

    • 08/04/12 11:06am

      pjeaje says:

      Pretty much all the normal tag cloud arguments

    • 08/04/12 12:07pm

      pjeaje says:

      Any luck?

    • 08/04/12 12:46pm

      Jatin Soni says:

      Not yet, this require to create function or a small kind of plugin need more effort to put to make it works.

This question has expired.





Current status of this question: Community pot



Please log in to add additional discourse to this page.





Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.