If your site or post type doesn’t use Gutenberg, this is likely because of the wpautop
function: it is applied with priority 10
on the_content
filter, so the paragraph tags have already been added by the time your filter is running. Changing your callback’s priority to be less than 10
will likely solve your issue.
If your site/CPT does use Gutenberg, then an HTML parser will be necessary to add in your link. See the answer here:
https://stackoverflow.com/questions/2100692/get-last-li-element-from-a-string
Related Posts:
- Stop WordPress Wrapping Images In A “P” Tag
- Stop WordPress automatically adding tags to post content
- Get content from one page and show it on another page
- Strategy for handling hierarchical pages with empty parent content
- How to remove Nextpage tag inside posts text depending of utm_campaign
- How can you make sure authors’ posts are longer than 250 words?
- What is the best / efficient way to get WordPress content by post id and why?
- JSON not valid after json_encode posts
- Add default content to post (for specific category)
- Programmatically inserting page breaks
- Hide parts of the post content on the home page
- Filter/Remove HTML Elements on all posts and pages
- Paragraphs removed when using get_post_custom()?
- Load post content into div with ajax
- Testing for post title in ‘if/else’ statement returns no content
- Same content shared between multiple posts?
- how load content as pop-up using ajax
- How to get only text from wordpress post content?
- Batch process: remove first image from post content
- Why content_arr[‘extended’] removes paragraph tags?
- Unautop / Sanitize content added to a post through a plugin
- is there a way to show the the post title after the image?
- How to get rid of shortcodes in post content once and for all
- Add Word Limit to Posts
- Show only one page link in content pagination
- Show only posts with images and a fixed amount of posts
- How to create new post content templates for my users?
- How do I do a page break?
- How to get a post’s content? [closed]
- Why does a published post only displays the title and not the content in the site? [closed]
- Best Way to Add UnEditable HTML to Posts
- The_excerpt() doesn’t parse – how to change that?
- Page and post loop same template
- Benefits to using semantic HTML in post content? [closed]
- the_content() Not Grabbing All Content
- Can’t save WordPress post with “/etc/” in it
- content summary of a post disappears If an images added at the beginning of the post. how to solve it?
- Hide parts of the post content after typing it’s name or searching it by category
- How to exclude the word “class” from being matched in search?
- Preview page/post revisions without overwriting current content
- Posts and Pages w. private visibility don’t show up in existing content
- definining own teaser text for post
- Add text and change style to post programmatically depending on category
- why my urdu text is not aligned properly when written in wordpress blog post?
- How to Remove HTML Elements from Post Excerpt?
- My website is showing today’s date instead of published date since db migration to a new wordpress
- Related post not showing table of content
- How to get unmodified post content?
- I have inserted a post’s content in homepage.php by the post-id. The font isn’t matching with the theme. How do I change font of this content?
- How do I set content in my pages so that it remains permanent while blog posts are added below?
- Nothing appears using get_the_excerpt() in category.php
- WordPress each user has each content for a page,how to do that?
- Add caption to thumbnails in content
- Adding div to WordPress page content
- Adding editable content above posts
- How to get post_content while the post is being edited
- Custom template for different post types
- Correcting the content width when sidebar is inactive?
- Multiple approval from editors before publishing?
- Get part of a page url
- How can i show only 30% of the “the_content(“More…”)”?
- How to use wp_editor(); in functions.php then retrieve content in the template
- Add default content to post (for specific category)
- jquery: getting contents of #content field on post page
- Stripping tag from elements in post
- What does WordPress mean by they have full rights to content [closed]
- After the local installation of an old WP website I can see the homepage but I can’t access to the articles, why?
- wordpress pinboard theme [closed]
- Automatically search and replace link in content (pages/posts)?
- Notify/check if the content of a custom gutenberg block has changed on save_post
- How to display breadcrumb on category?
- Should we trust the post globals?
- how to limit edit_form_after_title hook to page and post edit only?
- Add a checkbox to post screen that adds a class to the title
- How to force update all posts after import
- How to have different content in the loop and single
- Make “Post published. View post” Open in a New Tab
- How to add in title a date but with other color, like in iMDb titles?
- How can I set a Post’s default visibility to private and pending review checked
- Blog Posts in Custom Menu
- How do I get blog posts to appear within CMS?
- Query values from a Post Object Repeater [closed]
- Multiple Loops Breaking Pages
- Hook for changing excerpt content when excerpt not set
- Display post number by category
- Custom Post Limit for homepage only without plugin?
- Optimizing the blog loop
- Adding a custom post type meta field to rss
- Using AJAX to filter posts without refreshing page
- Add class to global $post
- Multisite how to display merged posts from two sites and sort by latest date?
- Remove the URL author of post on all comments
- Very weird behaviour after removing WP pages
- How to add navigation arrows to manually slide through posts?
- how to chang preview of list of articles of one category?
- Make assigning post to a specific category equivalent to assigning it to all categories
- Retina for WordPress Posts
- Echo number of all users (subscribers, contributors, authors, etc.) whom have posted at least once
- How to create a cumulative posts and members count
- Optimize blog that serves hundred of images and videos