Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Is it possible to paste a link without tags and make it directly a link in a post?

I use a similar method to the following in a plugin of mine:

function wpse107488_urls_to_links( $string ) {
    /* make sure there is an http:// on all URLs */
    $string = preg_replace( "/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2", $string );
    /* create links */
    $string = preg_replace( "/([\w]+:\/\/[\w-?&;%#~=\.\/\@]+[\w\/])/i", "<a target=\"_blank\" title=\"" . __( 'Visit Site', 'your-textdomain' ) . "\" href=\"$1\">$1</a>", $string);

    return $string;
}

I don’t use it for post content, but it should work there.
For that, you’d have to employ the the_content filter:

add_filter( 'the_content', 'wpse107488_urls_to_links' );

Sidenotes:
This is untested.
The regexes are fairly good, but they will fail in niche cases once in a while. Identifying a URL by format only, while avoiding false positives isn’t the simplest of things.

Related Posts:

  1. How does WP decide how to display a page
  2. External link not showing on post but showing on comment
  3. Custom permalink for each post
  4. How to make Link to go on the first post
  5. How can I tell if a post has been published at least once?
  6. Is there a way getting post fields using `transition_post_status`
  7. Automatic blog page with custom design [closed]
  8. Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
  9. Add multiple meta keys to a post at once
  10. Show number of posts by logged in user
  11. Link to date_query results in WordPress
  12. Exists filter or action that change Add New Post link?
  13. When sending a newsletter -not with wordpress- the server has 100% cpu [closed]
  14. Display on page every post in blog WITH comments
  15. Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
  16. Insert data from custom created PHP page into wp_postmeta table
  17. Showing recent post of category in page
  18. Adding a meta box to determine the sidebar [closed]
  19. The loop starting at a certain ID
  20. Can WordPress handle following functionalities?
  21. saving/reading custom field value does not work – no value gets POSTed
  22. Simple Custom Metabox Not Saving
  23. Internal linking to posts permalink fail because of spaces and stripe at postname
  24. If post exists, make it a comment in existing post with same name?
  25. Get post category as a separate string and url
  26. Authors’ Links on Homepage Not Going to Author Post Pages
  27. Short link to read complete post
  28. Delete all Tag Links from Posts
  29. Link from Post to Another Post Via Clicking on Words within Original Post
  30. Link to older links
  31. How to link post titles on page A to its posts on page B?
  32. How to get post id of last approved comment?
  33. How to create several Post pages
  34. How to implement a WordPress comments function?
  35. Allow / show post comments in category pages
  36. Why the internal link get converted into a comment?
  37. Remove all external links from posts
  38. Featured Images most often doesnt appear
  39. Count the total views of all user posts published
  40. Edit post & page option does not display on latest wordpress
  41. Post meta not working
  42. how to show comments only author which send own posts in wordpress
  43. Shortcode for Comments and Comment Boxes in Post Loop
  44. Merge get_comments & get_posts into a single query
  45. How to bulk Update URLs to new values?
  46. Select another post in a post meta like a parent page is selected while editing a page
  47. SQL DELETE multiple post_meta on single and multi-sites
  48. Add data attribute of post_id for Internal links
  49. Prevent the automatic URL linking added in last update
  50. WordPress 5: prevent link from displaying page title instead of URL
  51. Some custom post types did not return an object
  52. How do I remove all links from all my posts at once?
  53. Private post caught in endless redirect loop
  54. How to retrieve all meta data directly from the $post object? Such as $post->related_topics?
  55. What is proper filter or hook action to add data to the $post object?
  56. Remove the URL author of post on all comments
  57. Blogposting Schema & Structured Data without plugin
  58. Automatically select template based on query string for New Posts
  59. WordPress weird behaviour on comments
  60. Display Updated Date Instead of Published Date
  61. Comments are in database, don’t show up in WordPress backend or frontend
  62. No comments allowed
  63. How do you update post date (year only) in a separate custom field?
  64. I want to change the WordPress comments file
  65. Add postmeta to all blog posts
  66. Creating a link to the first post in a category
  67. Bulk Post update_post_meta
  68. Re-order Category Meta-data
  69. How to hide meta from search result only on pages?
  70. WP_Query sort by meta_value_num or date
  71. Post Category link is same with Page link
  72. Grab meta data before post is saved
  73. How to fetch posts that are stored in the different table than the default table (wp_posts)?
  74. Check if user has avatar
  75. alt of attached image in post / pages
  76. Creating Ordered Query using Meta_key
  77. Posting a comment redirects admin/users to blank page
  78. Best Way to detect unique posts in wp rest api
  79. Get the correct meta_value with get_post_meta
  80. post_name is not stored until post is published… where should I store my slug until it goes live then?
  81. Filter question list on substring of metavalue
  82. Add a meta to a post submited from a frontend form
  83. How to enable comments meta box for other author posts?
  84. Post List Widget with custom posts and editing the Read More Link
  85. Comments as part of a post
  86. How to add a class to links inside posts text
  87. Show posts between two Custom Fields date
  88. Add custom class to existing menu items from custom meta
  89. Some comment box wordpress in 1 post [closed]
  90. How to get only current images of a post
  91. Ordering posts alphabetically by meta keys and title
  92. Run function after post is updated
  93. No comments on static front page
  94. Featured Images link to post parent
  95. 3rd Party Login in wordpress
  96. Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
  97. My posts section for logged in user
  98. Trash a post, send associated comments into the trash bin (change status)
  99. Apply comment to different post (not the current post) [duplicate]
  100. Adding custom fields to the Quick Edit screen – puzzled about the column concept
Categories posts Tags comments, links, post-meta, posts
Specific routing for CPT
wordpress changing host breaks image links

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress