WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The users of my site mainly share documents by inserting links into content (pages/posts) using the built in editor. These files include everything from pdfs to word documents. The users currently get/copy these links from a php file manager like FileRun. My goal is to have the users instead use a path from mapped network drive such as \testdrive\Folder1\Folder2\test.txt. The following function has been written to handle replacing the mapped network drive files to an internet link such as "http://page.test.org/files/".

function test_test_url_parse($string)
// Called by test_test_url_parse_wrapper()
// The nature of preg_replace means this needs a seperate function
    foreach ($bits as $bit)
    return "\"http://page.test.org/files/".implode("/",$bobs)."\"";

function test_test_url_parse_wrapper($string)
//Finds/replaces UCNs with URLs in the provided string. 
    return preg_replace($pattern1, "test_test_url_parse('$1')", $string);

Where could I put a function like this to automatically look through the content of a page or a post and replace the filepath accordingly? Would there theoretically be any way to put this just in the child theme? Currently when I upload media such as photos, it is already putting the files into the path "http://page.test.org/files/". I'm really looking for have function go through the post/page content and perform essentially a constant "search and replace"

share|improve this question

There is somewhat similar answer in the below mentioned link:

Removing any and all inline styles from the_content()

where some inline style are being removed with the help of preg_replace and wordpress hooks (wp_insert_post_data & the_content).

Similarly any part of the content can be modified with the as the same done in this (Removing any and all inline styles from the_content()) case.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.