Your code only works if you are actually calling wp_get_attachment_link()
somewhere in your template. If you’re not calling the function, then the apply_filters()
inside the function will never get called, and therefore your code will have nothing into which to hook.
Related Posts:
- remove links from images using functions.php
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- Best way to programatically add “rel” attributes to page and post images
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- How to Add A Rel Filter to All Links?
- Remove Actions/Filters added via Anonymous Functions
- Add class to menu items of one specific menu (nav_menu_css_class)
- How to influence the information displayed on widget inside wp-admin
- How to restrict actions and filters “properly” by conditions
- Filter the query ONLY for the search results page
- How to add classes to images based on their categories?
- Using add_filter() in Widgets
- Customize WordPress Media Manager – Media Window
- Is it possible to use a forgot password url filter?
- Wrap gutenberg block ‘div’ in other elements/extra HTML
- Remove Page Title from Static Frontpage
- Default or Preset Content for Custom Post Types
- Override a class function to include a custom template
- How to add a rel attribute to images that contains their categories?
- Exclude Empty Child Categories in Menu
- add_filter priority problem
- Clean-up script tags
- How to use IF Statement in WordPress?
- Gravity Forms field entries into wp_query loop [closed]
- Find first image on paginated post for Pinterest
- Post Pagination Showing Same Posts Every Page
- modify a function filter
- Super simple shortcode not working
- How would go about if I just want a temporary function?
- Generating rel=prev and rel=next only on wordpress categories
- How to make applyFilters function return false via functions.php
- How to filter out shortcode when displaying the_excerpt() in the loop?
- Accepted arguments value in hook functions
- Get current page_id before loop, in functions.php
- Change Rating range in Link Manager
- Which action hook to use for function?
- str_replace function in theme
- How to automatically remove links from WordPress Biographical Info?
- Last updated date function
- Modify a function without editing template
- How to set default archive image without overriding first attached image? [closed]
- How to add nav menu items to a specific position within a menu
- Disable auto-resizing of uploaded images, but only for certain filename
- How to make custom column Admin>Users sortable?
- Filter out other users comments. Visualize only own comments and editor role users’ comments
- Get Current Post ID in functions php, meta query filter
- Output and filter data from a XML url
- Add to cart php not working [closed]
- Is possible add icon in title posts only in specific tag?
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- create filter in functions.php
- How to filter $content in shortcode function
- Insert image in WordPress with HTML5 tag and caption function
- How to construct function for applying filter?
- Adding an external HTML link to a post thumbnail
- woocommerce change currency per category [closed]
- Add Element as a Filter to the_content
- How can I add a filter for specific categories on functions.php?
- Can’t properly set the_title add_filter to show short_URL
- (Woocommerce) Order by price when entering specific category
- Filter an WordPress Function in (general-template.php)
- attachment page template? only show attachments for current post?
- Filter nav menu items HTML tags and wrap inner text with span
- How can I add a class to a nav li depending on URL?
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- Using Static HTML instead of the `home_url()` WP function
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- How to add custom li item to wordpress menu
- Is it possible to use add_filter in an included file in the child theme’s functions.php?
- Insert Content Before div#main from the functions.php File
- Problem with images URL after filter applying
- remove/hide wp-editor
- How to convert raw url to hyperlink?
- Changing the text of Upload/Insert on Posts and Pages Screen
- Conditional custom menu?
- Get URLs for AJAX Filter Checkboxes WordPress
- How to display an image before title text in menu items
- Filter works on last selection but no others
- Overwrite text in a complicated filter hook
- WP_Query for Attachments not working as expected
- Save_post – Warning: Cannot modify header information
- custom error message for empty username and password using authenticate filter not working
- Add #primary at the end of navlink permalinks on single posts
- OOP Switch statement with array as parameter
- How to add class dynamically from templates
- Prevent function from triggering on current page
- Assign IDs to headings in ACF using functions.php
- Redirect specific author posts to another url
- Remove all video attachment, both files and post/postmeta from database?
- $content is empty while using DOMDocument
- Best way to add image to recent posts widget?
- How to make an If Else on Excerpt Filter
- Regex works in regexr, but not if I filter content [closed]
- Retrieve a custom form field modified by a filter
- Print all inline styles to head
- Function Reference for custom link in Admin Menu Management Page
- Force resize for all video content
- Way of getting queried loop before the query with a filter hook?
- Trying to get this function to show below the content
- function to show youtube videos within excerpt – if condition and apply_filters