{"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 This filter can be used to modify the output of\u00a0 In the following example, the output is modified using the filter. Once the code is applied (for example when added to\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>
%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>
functions.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>