WPJAM「分类管理插件」是 WordPress 果酱出品的全能型分类管理插件,这个插件目前主要有七大功能:
介绍 Taxonomy : NCBI公共序列数据库中所有生物的策划分类和命名法。目前包含地球上大概10%的物种。 我们现在查询到底包含有有多少物种,进入统计页面:。 查询某个物种的全部核酸序列和蛋白序列 进入 NCBI 首页 点击Taxonomy,进入物种分类数据库 进入 Taxonomy 首页,输入human,点击Search 浏览该物种下的核酸序列或蛋白序列 查看某个物种的其他信息(蛋白结构,基因,测序数据,相关文献等) https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi? 左栏显示人类拉丁名Homo sapiens,Taxonomy编号为txid9606,基因密码子表,线粒体密码子表等。 编号在查询和标注信息时候常常用到,比如,在Nucleotide中查询现代智人的时候: Taxonomy 的相关数据下载 ftp://ftp.ncbi.nih.gov/pub/taxonomy/
之前读 ete3 的帮助文档的时候看到过类似的功能http://etetoolkit.org/docs/latest/tutorial/tutorial_ncbitaxonomy.html。最近可能会用到这个功能,记录自己使用的代码 (首先是安装ete3:自己windows10电脑安装了Anaconda3,直接在DOS窗口下使用命令pip install ete3即可安装)
woocommerce(下称wc)的archive-product.php模板是定义shop page的,可能比较比较早版本的wc也是用这个文件来定义分类的,但是如果你升级到最新版本的wc会有一个单独的taxonomy-product_cat.php includes the archive template * * This template can be overridden by copying it to yourtheme/woocommerce/taxonomy-product_cat.php wc_get_template( 'archive-product.php' ); 但一定要重新定义这个文件,特别是使用了独立pc和mobile模板,你可以复制一份archive-product.php然后重命名成taxonomy-product_cat.php
表 一个 term 不能由它自己决定是 category(分类)还是 tag(标签),它必须通过 term_taxonomy 这个数据表来决定: term_taxonomy_id bigint(20) ), UNIQUE KEY term_id_taxonomy (term_id,taxonomy), KEY taxonomy (taxonomy) 字段 描述 term_taxonomy_id term +taxonomy 对的唯一 ID term_id terms 表外键 ID taxonomy 指定了 term 属于什么分类模式,默认的分类模式有 “category”,“link_category” parent 指定 terms 在 taxonomy 中层次关系 description 指定 term 在 taxonomy 中定义的描述 count 记录在每个 term+taxonomy 对中有多个对象 (term_taxonomy_id) 字段 描述 object_id post 或者 link 的 ID term_taxonomy_id 来自 term_taxonomy 表的外键 ID term_order
if($taxonomy->name == 'category'){ $taxonomy_key = 'cat'; }else{ $taxonomy_key = $taxonomy empty($_REQUEST[$taxonomy_key])){ $selected = $_REQUEST[$taxonomy_key]; }elseif(! empty($_REQUEST['taxonomy']) && ($_REQUEST['taxonomy'] == $taxonomy->name) && ! empty($taxonomy->query_var) && ! 'taxonomy' => $taxonomy->name, 'show_option_all' => $taxonomy->labels->all_items, 'show_option_none
可以按照以下sql语句进行操作(需要指定对应分类的id): select post_title from wp_posts,wp_term_relationships,wp_term_taxonomy where ID=object_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and post_type="post" and post_status = "publish" and wp_term_relationships.term_taxonomy_id = 197 and = wp_term_taxonomy.term_taxonomy_id,这里指的是表wp_term_relationships和表wp_term_taxonomy,他们有共同的字段term_taxonomy_id = "category",taxonomy是wp_term_taxonomy里面的分类方法字段,category表示分类方法为文章分类。
项目」怎样改成自定义分类模式的名称呢,下面这个代码可以解决这个问题: add_filter('term_updated_messages', function($messages){ global $taxonomy ; if($taxonomy == 'post_tag' || $taxonomy == 'category'){ return $messages; } $labels = get_taxonomy_labels (get_taxonomy($taxonomy)); $label_name = $labels->name; $messages[$taxonomy] = array_map(function(
= $wpdb->get_row("SELECT tt.term_taxonomy_id from $wpdb->terms t join $wpdb->term_taxonomy tt on t.term_id = tt.term_id where t.name = '每天60秒读懂世界' and tt.taxonomy = 'category' ")->term_taxonomy_id; if (! $term_taxonomy_id) { $wpdb->query("insert into $wpdb->terms (name,slug,term_group)VALUES('每天60秒读懂世界 (term_id,taxonomy,description,parent,count)VALUES($category_id,'category','','0','1')"); $term_taxonomy_id = $wpdb->insert_id; } $post_tag_arr[] = $term_taxonomy_id; $html = $content; //标题 $title = $date->
WordPress 竟然没有一个根据 $term_id 获取分类模式 taxonomy 的函数,那就自己写一个: function get_term_taxonomy($id){ $term = get_term $term->taxonomy : null; } 这样在其他代码中就方便调用了,并且还处理了返回是 WP_Error 的情况。 哪一天如果 WordPress 自己也支持了? function_exists('get_term_taxonomy')){ function get_term_taxonomy($id){ $term = get_term($id); $term->taxonomy : null; } } 好,非常完美,加入 WPJAM Basic,下一版本上线的时候,就有该函数了。
' ); 为避免下降if,它$query['taxonomy']需要为空或is_taxonomy_hierarchical返回 false的值。 该函数transform_query将检查query['field'] == resulting_field,如果为真,则返回并且不做进一步处理,所以如果变量query['field']是term_taxonomy_id 所以总而言之,要发生 SQL 注入,必须满足两个条件: $query['field'] term_taxonomy_id $query['taxonomy'] 或 is_taxonomy_hierarchical ($query['taxonomy']) === false 导致以下错误: 虽然这是wordpress核心的错误,但是wordpress核心使用的方式并没有触发错误,所以我转而寻找插件和主题的错误 ","terms":["<inject>"]}}} 或者 query_vars={"tax_query":{"0":{"taxonomy":"nav_menu","field":true,"terms
1;//分类id $sql="SELECT ID,post_title,post_content FROM wp_posts,wp_term_relationships,wp_term_taxonomy WHERE ID=object_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and post_type='post' and post_status = 'publish' and wp_term_relationships.term_taxonomy_id = $CID and taxonomy WHERE ID=object_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and post_type='post' and post_status = 'publish' and wp_term_relationships.term_taxonomy_id = $CID and taxonomy
回到clean_query函数,没有这个改变,默认情况下query['terms']中的值只会被删除,然后调用this->transform_query(query, 'term_taxonomy_id ');为避免 if,query['taxonomy']需要为空或is_taxonomy_hierarchical的值返回false。 总而言之,要产生 SQL 注入,必须满足两个条件: (1)$query['field'] 是 term_taxonomy_id (2)query['taxonomy'] 为空或 is_taxonomy_hierarchical (query['taxonomy']) === false 0x02开发: 虽然这是wordpress核心的错误,但是wordpress核心使用的方式并没有触发错误,所以我转而寻找插件和主题的错误。 ","terms":[""]}}} 或者 query_vars={"tax_query":{"0":{"taxonomy":"nav_menu","field":true,"terms":[""]}}}
.==2) { @samples=@arr; next; } my $taxonomy=$arr[$#arr]; $taxonomy=~s/;/|/g; $taxonomy= ~s/(k|p|c|o|f|g|s)__//g; $taxonomy=~s/\s+|\[|\]//g; $taxonomy=~s/\|*$//g; my @taxoArr=split(/\|/,$ taxonomy); my $taxSetp=""; for(my $tax=0;$tax<=$#taxoArr;$tax++) { if($tax==0) { ; #print WF "Taxonomy"; #for(my $i=1;$i<$#samples;$i++) #{ # print WF "\t" .
WHERE ID=object_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and post_type='post' and post_status = 'publish' and wp_term_relationships.term_taxonomy_id = $CID and taxonomy WHERE ID=object_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and post_type='post' and post_status = 'publish' and wp_term_relationships.term_taxonomy_id = $CID and taxonomy taxonomy=category ? ? ---- 访问php文件后,会得到当前目录的所有文章ID 将ID保存到NotePad++ ? ?
1;//分类id $sql="SELECT ID,post_title,post_content FROM wp_posts,wp_term_relationships,wp_term_taxonomy WHERE ID=object_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and post_type='post' and post_status = 'publish' and wp_term_relationships.term_taxonomy_id = $CID and taxonomy
FROM $wpdb->posts AS p INNER JOIN $wpdb->term_relationships AS tr ON (p.ID = tr.object_id AND tr.term_taxonomy_id = $random_cat_id) INNER JOIN $wpdb->term_taxonomy AS tt ON(tr.term_taxonomy_id = tt.term_taxonomy_id AND taxonomy = 'category') WHERE post_type = 'post' AND post_password = '' AND post_status = 'publish
taxonomy (string) – 分类模式. field (string) – 如何获取分类模式(Taxonomy term),可能的值有:「term_id」,「name」,「slug」或者「term_taxonomy_id terms (int/string/array) – Taxonomy term(s),和 field 参数对应,上面制定了字段,这里则指定对应的值。 new WP_Query(array( 'post_type' => 'post', 'tax_query' => array( array( 'taxonomy ' => 'slug', 'terms' => array( 'quotes' ), ), array( 'taxonomy ' ), ), array( 'relation' => 'AND', array( 'taxonomy
DISTINCT ID, post_title FROM {$wpdb->prefix}posts, {$wpdb->prefix}term_relationships, {$wpdb->prefix}term_taxonomy WHERE {$wpdb->prefix}term_taxonomy.term_taxonomy_id = {$wpdb->prefix}term_relationships.term_taxonomy_id AND ID = object_id AND taxonomy = 'post_tag' AND post_status = 'publish' AND post_type = 'post' AND WHERE {$wpdb->prefix}posts.ID = {$wpdb->prefix}term_relationships.object_id AND {$wpdb->prefix}term_taxonomy.taxonomy = 'category' AND {$wpdb->prefix}term_taxonomy.term_taxonomy_id = {$wpdb->prefix}term_relationships.term_taxonomy_id
遂开始准备从数据库入手,教程如下:导入主要涉及到3个表wp_termswp_term_relationshipswp_term_taxonomy字段说明:wp_termsterm_idnameslug标签 id标签名称别名(url名称)导入内容: 标签id、标签名称、别名wp_term_relationshipsobject_idterm_taxonomy_idterm_order绑定文章id关键词id可留空 wp_term_taxonomyterm_taxonomy_idterm_idtaxonomy关键词id关键词id+1post_tag导入演示wp_termsterm_idnameslug可留空,让系统自动生成 或者设置别名(非必须,可省略留空)wp_term_relationshipsobject_idterm_taxonomy_idterm_order5538551904post_tag5538551905post_tag 导入内容: 文章id、标签id、字段类型 (此处标签id是根据第一张表导入后,提取出来的标签id) 第二张表导入标签id要绑定的文章,(标签与文章之间存在嵌套关系)wp_term_taxonomyterm_taxonomy_idterm_idtaxonomy5190351904post_tag5190451905post_tag5190551906post_tag