{"id":2614,"date":"2022-03-22T15:03:47","date_gmt":"2022-03-22T09:33:47","guid":{"rendered":"https:\/\/imageattributespro.com\/?post_type=codex&p=2614"},"modified":"2022-03-22T15:03:48","modified_gmt":"2022-03-22T09:33:48","slug":"iaffpro_custom_attribute_tag_tag_names","status":"publish","type":"codex","link":"https:\/\/imageattributespro.com\/codex\/iaffpro_custom_attribute_tag_tag_names\/","title":{"rendered":"iaffpro_custom_attribute_tag_tag_names"},"content":{"rendered":"

The default output of\u00a0%tag%<\/code>\u00a0custom attribute tag of Image Attributes Pro is the first tag associated with a post. If a post has multiple tags, only one of them will be used while generating image attributes.<\/p>

This filter can be used to modify the output of\u00a0%tag%<\/code>\u00a0custom attribute tag.<\/p>

\/**\r\n * Filter the list of tags returned by %tag% custom attribute tag. \r\n * Default value is first tag name.\r\n * \r\n * @since 3.0\r\n * \r\n * @param $tags[0] (string) The first tag available. This is the default value.\r\n * @param $tags (array) Contains the names of all tags associated with $parent_post_id.\r\n *\/\r\nreturn apply_filters( 'iaffpro_custom_attribute_tag_tag_names', $tags[0], $tags );<\/code><\/pre>

Example Code<\/h2>

In the following example, the output is modified using the filter. Once the code is applied (for example when added to\u00a0functions.php<\/code>\u00a0of active theme),\u00a0%tag%<\/code>\u00a0will output a comma separated list of tags when a post has multiple tags.<\/p>

\/**\r\n * Generate a comma separated list of tags to be used as image attributes.\r\n * This modifies the output generated by %tag% custom attributes tag in Image Attributes Pro.\r\n * \r\n * @link https:\/\/imageattributespro.com\/codex\/iaffpro_custom_attribute_tag_tag_names\/\r\n * \r\n * @param $first_tag (string) The first tag available.\r\n * @param $tags (array) Contains the names of all tags associated with given post.\r\n * \r\n * @return (string) Comma separated list of all tags.\r\n *\/\r\nfunction prefix_iap_add_all_tags_in_custom_attribute_tag_tag( $first_tag, $tags ) {\r\n\r\n    \/\/ Returns all tags as a comma separated list. \r\n    return implode( ',', $tags );\r\n}\r\nadd_filter( 'iaffpro_custom_attribute_tag_tag_names', 'prefix_iap_add_all_tags_in_custom_attribute_tag_tag', 10, 2 );<\/code><\/pre>

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

post. If a post has multiple tags, only one of them will be used while generating image attributes. This filter can be used to modify the output of\u00a0%tag%\u00a0custom attribute tag.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"codex-type":[27],"class_list":["post-2614","codex","type-codex","status-publish","format-standard","hentry","codex-type-filters"],"_links":{"self":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/2614"}],"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=2614"}],"version-history":[{"count":1,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/2614\/revisions"}],"predecessor-version":[{"id":2615,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/2614\/revisions\/2615"}],"wp:attachment":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/media?parent=2614"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/tags?post=2614"},{"taxonomy":"codex-type","embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex-type?post=2614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}