Solved

Wordpress: search/replace when post saved

Posted on 2014-10-08
2
180 Views
Last Modified: 2014-10-08
I want to put a snippet in my functions.php that will search/replace a string in $content as the post is saved.

I haven't been able to find any examples of that.

Can you show me how to do this?

Thanks,

Chris
0
Comment
Question by:St_Aug_Beach_Bum
2 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
Comment Utility
It would look something like this:

function my_sanitize_content( $content ) {
    return str_replace( "Chris", "Jason", $content );
}
add_filter( 'content_save_pre' , 'my_sanitize_content' , 10, 1);

Open in new window


ref: http://codex.wordpress.org/Plugin_API/Filter_Reference/content_save_pre
0
 

Author Comment

by:St_Aug_Beach_Bum
Comment Utility
That's the ticket :) Thank you!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now