wordpress API

wordpress 的 single_term_title, get_term_by

日期:2014-10-04 阅读:1748

dmandwp系统 - wordpress系统和DM系统区块建站>>

http://codex.wordpress.org/Function_Reference/single_term_title   in wp-includes/general-template.php.
single_cat_title,  single_tag_title

http://codex.wordpress.org/Function_Reference/get_term_by  --- in wp-includes/taxonomy.php.得到TERM对象

------------

$termname= single_cat_title('', false);  ---得到自定义的term

if(is_category()) $thisCatseo = get_category(get_query_var('cat'),false);  ---得到自定义的categor

-----------

 <?php
//get terms by taxonomy----------//https://codex.wordpress.org/Function_Reference/get_terms
 $terms = get_terms('productscate', array(  
   'orderby'    => 'id',
    'order'    => 'desc',
 ) );

 //$terms =  wp_get_object_terms( '873',  'productscate' );
 //wp_get_object_terms( $post->ID,  'product' );  
 //https://codex.wordpress.org/Function_Reference/wp_get_object_terms

wp_get_object_terms 这个可以得到post id所在的所有的terms,并可以order by term_order

<?php wp_get_object_terms( $object_ids, $taxonomies, $args ); ?>

Retrieves the terms associated with the given object(s) in the supplied taxonomies.

------------
//https://developer.wordpress.org/reference/functions/get_the_terms/

get_the_terms : Retrieve the terms of the taxonomy that are attached to the post.

get_the_terms( int|object $post, string $taxonomy )


 //pre($terms);

 foreach ($terms as $v) {
      $name = $v->name;
      $slug = $v->slug;
      $catelink = get_term_link( $slug, 'productscate');

........

}

 

<<点击返回