taxonomy

How do I get current taxonomy term id on WordPress?

独自空忆成欢 提交于 2019-11-28 14:36:07
问题 I've created a taxonomy.php page in my WordPress theme folder. I would like to get the current term id for a function. How can I get this? get_query_var('taxonomy') only returns the term slug, I want the ID 回答1: Nevermind! I found it :) get_queried_object()->term_id; 回答2: Here's the whole code snippet needed: $queried_object = get_queried_object(); $term_id = $queried_object->term_id; 回答3: Simple and easy! get_queried_object_id() 回答4: Just copy paste below code! This will print your current

Query multiple custom taxonomy terms in Wordpress 2.8?

狂风中的少年 提交于 2019-11-28 08:49:05
I created a custom taxonomy named 'technologies' but cannot query multiple terms like I can with categories or tags. These querys DO work: query_posts('tag=goldfish,airplanes'); query_posts('technologies=php'); However, neither of the following work correctly: query_posts('technologies=php,sql'); query_posts('technologies=php&technologies=sql'); My objective: Show all posts with a technology of 'php' and all posts with a technology of 'sql' Any ideas? Is this even possible? Thanks! Apparently query_posts cannot help in this specific situation. (Hopefully it will be added in future versions of

Wordpress - Custom Taxonomy Pagination

喜欢而已 提交于 2019-11-28 08:30:48
问题 I'm using: Wordpress 3.4 WP-PageNavi 2.82 I register custom taxonomy ( catalog ) <?php add_action('init', 'pca_register_taxonomy', 0); function pca_register_taxonomy() { register_taxonomy('catalog', null, array( 'label' => __('Catalogs', __), 'labels' => array( 'name' => __('Catalogs', __), 'singular_name' => __('Catalog', __), 'search_items' => __('Search Catalogs', __), 'popular_items' => __('Popular Catalogs', __), 'all_items' => __('All Catalogs', __), 'parent_item' => __('Parent Catalog'

How to find “related items” in PHP

 ̄綄美尐妖づ 提交于 2019-11-27 19:28:42
we often see 'related items'. For instance in blogs we have related posts, in books we have related books, etc. My question is how do we compile those relevency? If it's just tag, I often see related items that does not have the same tag. For instance, when search for 'pink', a related item could have a 'purple' tag. Anyone has any idea? There are many ways to calculate similarity of two items, but for a straightforward method, take a look at the Jaccard Coefficient. http://en.wikipedia.org/wiki/Jaccard_index Which is: J(a,b) = intersection(a,b)/union(a,b) So lets say you want to compute the

Query multiple custom taxonomy terms in Wordpress 2.8?

↘锁芯ラ 提交于 2019-11-27 02:27:01
问题 I created a custom taxonomy named 'technologies' but cannot query multiple terms like I can with categories or tags. These querys DO work: query_posts('tag=goldfish,airplanes'); query_posts('technologies=php'); However, neither of the following work correctly: query_posts('technologies=php,sql'); query_posts('technologies=php&technologies=sql'); My objective: Show all posts with a technology of 'php' and all posts with a technology of 'sql' Any ideas? Is this even possible? Thanks! 回答1:

How to find “related items” in PHP

吃可爱长大的小学妹 提交于 2019-11-26 19:56:26
问题 we often see 'related items'. For instance in blogs we have related posts, in books we have related books, etc. My question is how do we compile those relevency? If it's just tag, I often see related items that does not have the same tag. For instance, when search for 'pink', a related item could have a 'purple' tag. Anyone has any idea? 回答1: There are many ways to calculate similarity of two items, but for a straightforward method, take a look at the Jaccard Coefficient. http://en.wikipedia