wp_get_attachment_link filter help
-
Looking inside the post-template.php file I see this.
........ /** * Filter a retrieved attachment page link. * * @since 2.7.0 * * @param string $link_html The page link HTML output. * @param int $id Post ID. * @param string $size Image size. Default 'thumbnail'. * @param bool $permalink Whether to add permalink to image. Default false. * @param bool $icon Whether to include an icon. Default false. * @param string|bool $text If string, will be link text. Default false. */ return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text );And I would really like to add my own class to all attachment generated links by WordPress.
So I tried to use the filter like this.function my_attachment_link_class( $link_html ) { $link_html = str_replace( '<a', '<a class="test"', $link_html ); return $link_html; } add_filter( 'wp_get_attachment_link', 'my_attachment_link_class' );But for some reason I can’t get the default url markup, replace it and return it. ?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘wp_get_attachment_link filter help’ is closed to new replies.