I want to list tags of my current post  I am using below code  &lt;?php $tax_tags = get_terms(array('post_tag'));    foreach($tax_tags as $tag){      ?&gt;        &lt;p&gt;      &lt;?php echo ucfirst($tag-&gt;taxonomy).' : ' ?&gt;          &lt;a href="&lt;?php echo get_term_link($tag); ?&gt;"&gt;&lt;?php echo $tag-&gt;name ?&gt;&lt;/a&gt;        &lt;/p&gt;      &lt;?php } ?&gt;   The output is   Post_tag : 1024x768  Post_tag : pics  Post_tag : india  Post_tag : 1366x768  Post_tag : 1920x1080  Post_tag : 1920x1200  Post_tag : 2015  Post_tag : 3d  But it shows list of all tags and i want to list tags which is related with Post ID = 17
122457
get_terms allows me to get all taxonomy values, but how do I limit this to a certain post?  I don't see anyway to feed a specific post ID to get_terms:   Perhaps there is another way to achieve this?
44861
The title says it all. At the moment in my custom taxonomies I'm getting the terms using the term id and taxonomy name.  Thought this question would've been asked before but can't find it anywhere! So just thought I'd ask and see if anyone has any answers.
120801
I couldn't find the right way to get the list of all products for a given category ID (not category name).  The code I am using to get the categories list is the following, it works fine:  $args = array(            'orderby'    =&gt; $orderby,            'order'      =&gt; $order,            'hide_empty' =&gt; 0,            'include'    =&gt; $ids,            'parent'    =&gt; 0,      );   $categories = get_terms( 'product_cat', $args );   However, now for a given category ID (say 47), I couldn't find the way to get its relevant products. I tried the following way:  $args = array(      'posts_per_page' =&gt; 5,     'offset'=&gt; 1,     'category' =&gt; 47  );  $products = get_posts( $args ); echo var_dump($products);   Debugging the $products array returns always 0 which is wrong since I know there is some products under the category with ID 47. Any ideas how to fix my code?
29752
I am trying to order posts by tag count. I want to order posts with no tags first and posts with highest count last.  I tried and got posts with no tags only.       $tags = get_tags();     $tag_ids = wp_list_pluck( $tags, 'term_id' );      $args1 = array (        'orderby'          =&gt; 'DEC',        'post_type'        =&gt; 'post',        'pagination'       =&gt; true,        'posts_per_page'   =&gt; '1',        'tag__not_in'      =&gt;  $tag_ids,        'meta_key'         =&gt; '_thumbnail_id',     );   How do I order posts based on the tags count?
25212
I want to list all sites in the multi site network in alphabetical order? Right now, the code lists by registered date  &lt;?php // Query for getting blogs             $blogs = $wpdb-&gt;get_results( $wpdb-&gt;prepare("SELECT blog_id, domain, path FROM $wpdb-&gt;blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb-&gt;siteid), ARRAY_A );              // put it in array               foreach ( (array) $blogs as $details ) {$blog_list[ $details['blog_id'] ] = $details;}             unset( $blogs );             $blogs = $blog_list;              // if is valid array             if (is_array( $blogs ) ){                     echo '&lt;ul&gt;';                     $array= array();                     // reorder                     $array= array_slice( $blogs, 0, count( $blogs ) );                     for($i=0;$i&lt;count($array);$i++){                     // get data for each id                     $blog = get_blog_details( $array[$i]['blog_id'] );                     // print it                     echo '&lt;li&gt;&lt;a href="'.$blog-&gt;siteurl.'"&gt;'.$blog-&gt;blogname.'&lt;/a&gt;&lt;/li&gt;';                     }                     echo '&lt;/ul&gt;';             }             ?&gt;
63107
I am in the process of creating a forum where user will be creating tags similar to the way Stack Overflow does.   To allow users to discover more and more questions, I liked the related tags in the right which comes when we visit a page of some particular tag.   So, I wanna know how two tags are considered related ? How can I calculate the distance between tags !  I just need the views or algorithm that can be used to calculate the distance.  Thanks !!
39731
This is on Stack Overflow. On Meta I'm able to see what the tags are on the right side of the screen. In fact, I think yesterday or some point earlier today I saw tags on the right side of the screen (I can't screenshot or remember correctly).  It's right above the asked and active heading.  I know this is minor but what happened to it? It might be useful for browsing instead of having to look at the bottom of the question post.    Found an image on Google and it shows the tags on the right side of the screen:
102926
Searching for " should return a list of questions that have the tag [comments] but not the tag [feature-request]. The right hand sidebar says that, but the search results are identical to .    As random points out, the operator works, but seems to be broken if a minus sign is the first tag in the resulting search URL. This is a problem because the system re-orders the tags when you put them into the search box, always putting the one with the minus sign first.    Edit: Here's another behaviour that I haven't encountered until now. I was trying to pattern search for tags that contain 'array' but NOT include '-array', so I did the search . The resulting page shows the right tags with the right operators on them, but the results aren't being filtered properly (the first result includes [multidimensional-array]). So I simplified and  (1,960 results), and then  (1,963 results -- what??), which still included that first question with [multidimensional-array] on it. Something is not working right here.
26749
Is it possible to find out the tags that are old and have no tag wiki?  Wouldn't it be good to find out the tags without it and possibly have a proper wiki for them? It would improve the tags a lot IMO.
43594
I want to display custom type posts from a custom taxonomy category so I did this: $news = get_posts( array(     'posts_per_page' =&gt; -1,     'post_type' =&gt; 'news',     'tax_query' =&gt; array(             'taxonomy' =&gt; 'news_category',             'field' =&gt; 'term_id',             'terms' =&gt; 82,         ),     ) );  $postslist = get_posts( $news );      foreach ($postslist as $crap) { ?&gt;      &lt;a href=&quot;&lt;?php $crap-&gt;title; ?&gt;&quot;&gt;&lt;?php $crap-&gt;title; ?&gt;&lt;/a&gt; &lt;?php }?&gt;  I get nothing from this. Why is that? I double checked the category ID and its correct. Also, I used the Custom post types plugin to register the custom taxonomy.
27089
I am looking for a solution that allows me to print the following:  Cat 1        Cat 2        Cat 3  Post 1       Post 1       Post 1  Post 2       Post 2       Post 2  Post 3                    Post 3                            Post 4   EDIT  I am looking for something that will only require one database query! So if you have a foreach in your code followed by a new WP_Query then that is not what I am looking for (I am planning to put this onto my website's homepage).
119500
Is there a way for me to download the full list of tags (and synonyms) used on Stack Overflow? My intent is to import these tags into an SQLite database as part of a process to convert all of my delicious bookmarks and tags to the ones used here on Stack Overflow.
94872
I have taxonomy color which  is associated with a custom post type. I am listing all the post meta and the taxonomy  in a table. I have a option in the table  to search  the posts matching the search value.   when search key is entered it will do a ajax call to get the the posts.  this is the query to get all the posts matching the search string.  function get_query_posts_custom($post_id,$start,$length)  {     //get_posts arguments     $args =  array(         'post_type'     =&gt; 'custom_post',         'post_status'   =&gt; array('publish'),         'numberposts'   =&gt; $length,         'offset'        =&gt; $start,         'orderby'       =&gt; 'menu_order',         'order'         =&gt; 'asc',         'post_parent'   =&gt; $_product-&gt;id     );       //get custom post taxonomy     $taxonomies = (array) maybe_unserialize(get_post_meta( $post_id, 'post_taxonomy', true));     if(empty($attributes)) {         $taxonomies = array();     }      $meta_keys  = array('type','code','key');            if(!empty($search)) {         foreach($meta_keys as $meta_key) {             $meta_query[] = array(                         'key'   =&gt; $meta_key,                         'value' =&gt; $search,                         'compare'   =&gt; 'LIKE';                     );          }          $args['meta_query'] = $meta_query;         $tax_query = array();          foreach($taxonomies as $taxonomy) {             $tax_query  = array(                 'taxonomy'  =&gt;  $taxonomy;                 'field' =&gt;  'slug';                 'terms' =&gt;  $search;                 'operator'  =&gt; 'LIKE';             );         }         if(count($tax_query)) {             $args['tax_query'] = $tax_query;         }     }     $results    = get_posts($args);             return $results; }   How to get the posts that matches the search string of a taxonomy?  I searched the wordpress function reference  it says only operator allowed to tax_query are 'IN,NOT IN, OR and AND')  can I use the LIKE operator?
55412
I have a custom taxonomy (hierarchical) for which I'm outputting the results. For example's purpose:  --Drinks  ----Tequila  ------Reposado  ------Blanco  ----Beer &amp; Wine  ------Beer  ------Wine  --------Red  --------White  --------Rose  ----Whisky  ------Lowlands  ------Highlands  ------Islay   I have a loop that goes through and outputs the hierarchy--the problem is that I have ONE term  that goes a level deeper than the rest (the different types of wine: red, white, rose). Currently, my loop outputs  headings for each term, so the loop puts Red, White, Rose at the same level as the rest of the terms. What I need it to do is realize when a term is 3-levels deep, and instead output an  so that I can maintain the correct hierarchy.  All that to say: is there a way to determine a term's depth? if $term_depth = 4, then do this. If $term_depth = 4, then do this?  My loop:  $theCatId = get_term_by( 'slug', $currentslug, 'drink_cats' ); $termID = $theCatId-&gt;term_id; $taxonomyName = 'drink_cats'; $termchildren = get_term_children( $termID, $taxonomyName ); $termhier = _get_term_hierarchy($taxonomyName);  if (isset($termhier[$termID])) {                     foreach ($termchildren as $child) {         $term = get_term_by( 'id', $child, $taxonomyName );         $termname = $term-&gt;name;         // loop here to get $term depth?         // level 3         echo '&lt;h2&gt;'. $termname . '&lt;/h2&gt;';         // level 4 &lt;h3&gt;greatgrandchild&lt;/h3&gt;         $args = array(             'post_type' =&gt; 'menu_drinks',             'orderby' =&gt; 'menu_order',             'order' =&gt; 'ASC',             'posts_per_page' =&gt; -1,             'taxonomy'  =&gt; 'drink_cats',             'term'      =&gt; $term-&gt;slug         );         $drink_query = get_posts( $args );         if ($drink_query) {             echo '&lt;ul class="drink-group"&gt;';             foreach( $drink_query as $post ) {                    setup_postdata($post);                  $drinkdesc = get_field('drink_description');                 $drinkprice = get_field('drink_price');                 $drinkphoto = get_field('drink_photo');                 //output specific drink, description, price                 ?&gt;                  &lt;li&gt;                     &lt;h4&gt;&lt;?php the_title(); if ($drinkprice) { echo " - $" . $drinkprice; } ?&gt;&lt;/h4&gt;                     &lt;?php if ($drinkdesc) { ?&gt;                         &lt;p&gt;&lt;?php echo $drinkdesc; ?&gt;&lt;/p&gt;                     &lt;?php }?&gt;                                                 &lt;/li&gt;                  &lt;?php }         echo '&lt;/ul&gt;';         }     } }  else {      $args = array(         'post_type' =&gt; 'menu_drinks',         'orderby' =&gt; 'menu_order',         'order' =&gt; 'ASC',         'posts_per_page' =&gt; -1,         'taxonomy'  =&gt; 'drink_cats',             'term' =&gt; $currentpage     );      $drink_query = get_posts( $args );     echo '&lt;ul class="drink-group"&gt;';         foreach( $drink_query as $post ) :                setup_postdata($post);              $drinkdesc = get_field('drink_description');             $drinkprice = get_field('drink_price');             $drinkphoto = get_field('drink_photo');         ?&gt;                      &lt;li&gt;                             &lt;h4&gt;&lt;?php the_title(); if ($drinkprice) { echo " - $" . $drinkprice; } ?&gt;&lt;/h4&gt;                             &lt;?php if ($drinkdesc) { ?&gt;                 &lt;p&gt;&lt;?php echo $drinkdesc; ?&gt;&lt;/p&gt;             &lt;?php } ?&gt;                                                     &lt;/li&gt;          &lt;?php endforeach;      echo '&lt;/ul&gt;';        }   Thanks for you time--if anyone is interested, I can send a link to the dev server so you can see how the Beer &amp; Wine page outputs now, if this is unclear.
65517
I would like to ask that what code should i add in order to make my related posts by tag to display randomly? I got this code from somewhere else.  &lt;?php $orig_post = $post; global $post; $tags = wp_get_post_tags($post-&gt;ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag-&gt;term_id; $args=array( 'tag__in' =&gt; $tag_ids, 'post__not_in' =&gt; array($post-&gt;ID), 'posts_per_page'=&gt;5, // Number of related posts that will be shown. 'caller_get_posts'=&gt;1 ); $my_query = new wp_query( $args ); if( $my_query-&gt;have_posts() ) { echo '&lt;div id="related"&gt;&lt;h4&gt;Related Posts&lt;/h4&gt;'; while( $my_query-&gt;have_posts() ) { $my_query-&gt;the_post(); ?&gt; &lt;div class="ncc"&gt; &lt;h5&gt;&lt;a href="&lt;? the_permalink()?&gt;" rel="bookmark" title="&lt;?php the_title(); ?&gt;" rel="nofollow"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h5&gt; &lt;?php the_excerpt(); ?&gt;  &lt;/div&gt;&lt;!--ncc--&gt;  &lt;? } echo '&lt;/div&gt;&lt;!--related--&gt;'; } } $post = $orig_post; wp_reset_query(); ?&gt;   Any solution? Thanks!
12556
Basically on my site I have a bunch of song lyrics and in a static page I want to show them listed by album  and album position of the song and I have two custom fields with that data, sd_album_title and `sd_album_track_n. Plus some of the songs don't have an album yet, so both values are void, and I wish to list those ones at the foot of the others, sorted by alphabetical order.  The latest thing I tried at least to sort everything by the two field is this one:  $key = 'sd_album_title'; $themeta = get_post_meta($post-&gt;ID, $key, TRUE);  add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) {     if ($themeta != '') {         $query-&gt;set( 'post_type', 'lyric' );         $query-&gt;set( 'meta_key', 'sd_album_title' );         $query-&gt;set( 'orderby', 'meta_value' );         $query-&gt;set( 'order', 'ASC' );         $query-&gt;set( 'meta_query', array(               array(                     'key' =&gt; 'sd_album_title'               ),               array(                     'key' =&gt; 'sd_album_track_n',                     'value' =&gt; 'target_value',                     'compare' =&gt; '&gt;=',                     'type' =&gt; 'numeric'               )         ));     }     return $query; }  $getlist= 'my_get_posts'; $posts = get_posts( $getlist );   And my intention was to put an else at the end of it with an array ordered by title for the other songs, but it returns nothing as it is. Could something like this work with some corrections or am I on a totally wrong path?
7038
Here's the information :     There are four different pairs of   opening and closing tags which can be   used in PHP. Two of those, &lt;?php ?&gt;   and &lt;script language="php"&gt; &lt;/script&gt;,   are always available. The other two   are short tags and ASP style tags, and   can be turned on and off from the   php.ini configuration file. As such,   while some people find short tags and   ASP style tags convenient, they are   less portable, and generally not   recommended.   In my experience most servers do have short tags enabled. Typing  &lt;?=   is far more convenient than typing  &lt;?php echo    The programmers convenience is an important factor, so why are they not recommended?