Filters are for modifying values before they are output. Typically the function is passed some value where you can modify it or overwrite it, then pass the result back. Your link is appearing out of place because you’re outputting the value directly, change it to return
instead.
Also note that most template tags have versions that output their value, and ones that return. In your function the_permalink
is changed to get_permalink
.
add_filter( 'excerpt_more', 'edit_more_link', 11 );
function edit_more_link() {
return '<a class="read-more" href="' . get_permalink() . '?template=iframe">read more »</a>';
}
Related Posts:
- Get excerpt from $post->post_content
- How to use the_excerpt in a filter hook?
- add_filter on “the_excerpt” only works when post does not have excerpt
- End excerpt at the end of the sentence
- get_the_excerpt() with fallback like the_excerpt()
- How do I filter get_the_excerpt() but keep all of its functionality intact?
- Buddypress: Edit activity when new blog post [closed]
- Why in archive page doesn´t show read more button with excerpt?
- the_excerpt filter with an empty excerpt
- Access get_the_title() from ‘excerpt_length’ filter
- Give “Read More” precedence over excerpt() word count
- How do I override the_excerpt so that it will display full content?
- the_excerpt filter doesn’t work as expected
- Excerpt is being added above the content, but it should be after it
- run shortcode in excerpt of single custom post type
- apply_filters(‘get_the_content’, $content) + Except
- Trimming a custom field to a length
- Adding html banner to posts
- Apply wordpress filter checking category
- Add Filter – Pass Variable (PHP < 5.3)
- Filter Post Title without affecting screen-reader-text
- Create different flavours of excerpt
- Cutting off excerpt with first sentence
- Auto-generated excerpt with shortcode and read more button/text link
- Read More in the actual excerpt
- is_page_template() doesn’t work with excerpt_length filter
- the_excerpt() does not work with has_excerpt()?
- get_the_excerpt on mobile still displays continue reading
- Custom excerpt_more filter not working when tag is present
- Not able to change wp_title using add_filter
- How to hook a filter to catch get_post_meta when alternate a custom field output?
- Changing JPEG compression depending on image size
- Advanced Custom Fields and Yoast SEO keyword analysis [closed]
- Insert Custom HTML After Shortcode
- Is there a way to add another row to the tinyMCE kitchen sink toggle?
- What do add_filters() and apply_filter() do?
- add_filter to youtube embeds?
- SSL certificate for the host could not be verified
- Store source permalink on XMLRPC calls
- How to limit the pages displayed for choosing parent page on page attribute’s menu?
- How can I reliably and globally disable wptexturize?
- Customise Jetpack Publicize text
- Can’t change a label in woocommerce with the normal filter
- WordPress RSS feed – filter RSS content by custom field value
- What is the filter hook for custom fields content?
- Filter keywords from search query
- Add class to woocommerce checkout body based on filter [closed]
- Filter the URL of next_posts_link & previous_posts_link
- Explanation for remove_filter used in the below code [closed]
- How to change the blog title with add_filter? details below
- How To Get User Data in Callback Function for pre_user_nicename?
- What’s the best way to split admin-only functionality in the theme’s functions.php file?
- Editing
- the_content filter – checking the post
- add_filter to apply_filters that exists within class
- Which built-in WordPress files are safe to edit?
- How do I target a single page to modify the comment form of only that page?
- Adding a title prefix with the the_title filter
- How to removes all instances of thumbnails displayed in my theme?
- Contact Form 7 filter similar to preprocess_comment [closed]
- How to modify an existing meta description?
- Adding TinyMCE buttons without removing plugin buttons?
- How to customize the “Insert/edit link” popup box?
- How to filter backend post list showing only posts having a shortcode
- Why does WordPress strip custom HTML that are form elements and theme SVG icons?
- Get current user data
- How can you wrap add_filter with a if is_home() statement?
- How to add attributes to WordPress Admin Sub Menu List Items
- How do I hook my function to run only after submitting login form
- How to combine multiple body classes
- How to write a filter to remove a form field (WordPress) [closed]
- Why doesn’t this function work when I know that the IP Address is “true”?
- term_link filter rewrite link only applying half of condition?
- How to change dynamically page title according to variable data?
- Map plugin with proximity search compatible with Buddypress
- Create a pre-filtered version of the Media Library
- What is the action hook to use if you want to capture the new password during password change?
- Get_template_part inside filter?
- How to filter Sidebar Content
- Removing URL and adding container around image in the featured image metabox
- How would I use a filter to remove header banner on certain post types
- Replace Data In Post & Update Meta Field Post Is Saved
- How to add custom media library mime icons?
- Customising the default wordpress search functionality
- get_post() with filters applied
- Ajax filter – show all results that contain at least one filter
- WP_Query filter by custom meta
- How to add a blog filter bar without paying money. (example inside)
- Override admin selected page layout
- WordPress: Issue with filtering users using date range
- Does anybody know what the $current_screen ->id for customizer.php is?
- How to filter reading/visibility posts based on role?
- Filter and validate user role in registration
- wordpress filtering out caps in wp_title? (UpperCase is changed to Uppercase)
- String Replace Caching & Chance of Collisions
- Turn wp_tag_cloud into a front-end filter
- Add HTML to Page Content
- How can I define the RSS feed content length?
- GET form action. Redirect to self
- How to change this WP logo and posts url in block editor?