{"id":2596,"date":"2022-03-22T14:25:38","date_gmt":"2022-03-22T08:55:38","guid":{"rendered":"https:\/\/imageattributespro.com\/?post_type=codex&p=2596"},"modified":"2022-06-03T10:53:21","modified_gmt":"2022-06-03T05:23:21","slug":"iaffpro_custom_attribute_tag_tag_taxonomy","status":"publish","type":"codex","link":"https:\/\/imageattributespro.com\/codex\/iaffpro_custom_attribute_tag_tag_taxonomy\/","title":{"rendered":"iaffpro_custom_attribute_tag_tag_taxonomy"},"content":{"rendered":"\n

Filter the taxonomy name for %tag%<\/code> custom attribute tag to extend it to tags of other post types. By default %tag%<\/code> fetches the tag of the WordPress post<\/code> post type.<\/p>\n\n\n\n

The taxonomy name for the WordPress post<\/code>\u2018s tag is post_tag<\/code> and that of WooCommerce product tag is product_tag<\/code>.<\/p>\n\n\n\n

\"Taxonomy
Taxonomy name of WordPress Post Tag is post_tag<\/code>.<\/figcaption><\/figure><\/div>\n\n\n\n
\"Taxonomy
Taxonomy name of WooCommerce Product Tag is product_tag<\/code>.<\/figcaption><\/figure><\/div>\n\n\n\n
\/**\n * Filter $tag_taxonomy_name to extend %tag% custom attribute tag to other post types. \n * \n * Refer 3rd-party\/woocommerce.php for example code.\n * \n * @since 3.0\n * \n * @param $tag_taxonomy_name (string) Name of the taxonomy.\n * @param $post_type (string) will have the post type of the parent post where the image is used. \n *\/\n$tag_taxonomy_name = apply_filters( 'iaffpro_custom_attribute_tag_tag_taxonomy', $tag_taxonomy_name, $post_type );<\/code><\/pre>\n\n\n\n

Usage In Image Attributes Pro<\/h2>\n\n\n\n

The following code is from Image Attributes Pro version 3.0 and above where the filter is used to extend %tag%<\/code> to WooCommerce products.<\/p>\n\n\n\n

\/**\n * Add WooCommerce Product tag taxonomy to custom attribute tag %tag%.\n * \n * @since 3.0\n * \n * @param $tag_taxonomy_name (string) Name of the taxonomy.\n * @param $post_type (string) will have the post type of the parent post where the image is used.\n * \n * @return $tag_taxonomy_name (string) WooCommerce product tag taxonomy name ('product_tag') if $post_type is 'product'.\n *\/\nfunction iaffpro_add_wc_product_tag_to_custom_attribute_tag_tag ( $tag_taxonomy_name, $post_type ) {\n\n\t\/\/ Check if post type is WooCommerce product. \n\tif ( strcmp( $post_type, 'product' ) === 0 ) {\n\t\treturn 'product_tag';\n\t}\n\n\treturn $tag_taxonomy_name;\n}\nadd_filter( 'iaffpro_custom_attribute_tag_tag_taxonomy', 'iaffpro_add_wc_product_tag_to_custom_attribute_tag_tag', 10, 2 );<\/code><\/pre>\n\n\n\n

Related: iaffpro_custom_attribute_tag_category_taxonomy<\/a><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"

Filter the taxonomy name for\u00a0%tag%\u00a0custom attribute tag to extend it to tags of other post types. By default\u00a0%tag%\u00a0fetches the tag of the WordPress\u00a0post\u00a0post type.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":[],"tags":[],"codex-type":[27],"_links":{"self":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/2596"}],"collection":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex"}],"about":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/types\/codex"}],"author":[{"embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/comments?post=2596"}],"version-history":[{"count":4,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/2596\/revisions"}],"predecessor-version":[{"id":2854,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/2596\/revisions\/2854"}],"wp:attachment":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/media?parent=2596"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/tags?post=2596"},{"taxonomy":"codex-type","embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex-type?post=2596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}