Tagged: ,

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #27657

    When I create a post with “Link” Format, and try to link some text within the post to the SAME URL as is at the top, that URL gets stripped out of the text when the page is loaded in a browser. The Title/Headline does go to that URL — so the Link Format does work, and the URL does work. But the second link to the same URL, linked to some text within the post, is stripped out, when the page is loaded. If I go back to edit that post within the dashboard, the URL is still there in the a tag surrounding the text I am trying to link. There is nothing wrong with the HTML in the editor, but it doesn’t work in the browser. If I link a different URL within the post text editor, it works fine in the browser. The only problem is I can’t link the SAME URL as the one linked to the title by the Post Format of “Link.”

    If this is automatic, can you think of a workaround? Is there a way to link to the post ID or anything within the text or title so this format would not recognize them as being the same?



    Use tinyurl or google url shortener(http://goo.gl/).




    Thank you. The only problem with that is if I’m linking to content on my own site with a shortened URL, then I’d have to manually rewrite it every time I moved the site from my local server to the testing server to the final live server. I use BackupBuddy to handle rewriting all the URLs every time I move the site from the working environment to the live environment, and it would not rewrite the shortened URL to point to the relocated page.



    You can do this instead. Edit includes > helper-post-format.php, find these code on line 200 and 208:

    $current_post['content'] = str_replace($link, "", $current_post['content']);

    Remove it.




    This does allow both the title and another link in the post content to link to the same URL, but the first instance of the URL at the top of the content is now printed out at the top of the post content on the front end.

    If I add css to make just that first instance “display:none;” then the function “avia_link_content_filter” replaces the post title with the text of the second instance of the link.

    Is there a way to alter the function “avia_link_content_filter,” to replace only the first instance of the first URL in the content with ” “, while leaving the post title alone (so the post title stays as set in the post editor)?

    Since the function “avia_link_content_filter” is pluggable, I would like to copy it to my Child Theme’s function.php and alter it there.

    Thank you!



    In /includes/helper-post-format.php on one of these two lines is where it gets stripped out, try commenting out one line at a time to uncover which one works for you – lines 226, 234, is where the removal of the url from the body takes place I believe. Both lines look the same:

    $current_post['content'] = str_replace($link, "", $current_post['content']);

    Just add // in front.




    I tried commenting out only one of the 2 lines at a time, but that didn’t solve the problem either. If the removal of the line allows a second link, then that removal also causes the Link URL to appear printed out at the top of the post.

    Thanks for trying!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Second link in post with Link Format gets stripped out’ is closed to new replies.