I ended up just writing a function inside of my template’s index.php like this.
function fancySearchAndReplace() {
$regex = '/myregex/';
$my_posts = get_posts(array('post_type' => 'post', 'numberposts' => -1));
foreach ($my_posts as $post) {
$content = $post->post_content;
$theID = $post->ID;
$thing = get_field('thing', $theID);
$updatedContent = preg_replace($regex, $thing, $content);
wp_update_post(array(
'ID' => $theID,
'post_content' => $updatedContent,
));
}
}
Related Posts:
- Add custom options to the wplink dialog
- How to show page content in feed?
- Filter specific shortcode output?
- Insert new element to array with add_filter
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- How can I add information underneath the user’s name on the users.php page?
- Is calling function_exists() faster or slower that apply_filters()
- Filtered query_vars becomes global. Why does this work?
- How to disable all WordPress emails modularly and programatically?
- Allow Profile HTML for select users
- Alter only the page title, not the post titles within
- Load different template file when condition met?
- Search with filters and title
- Filter all html output
- Too many actions/filters!
- How can override a add_filter of a plugin?
- Adding Filter Conditionally Per Page ID
- failed to filter hook `get_terms_defaults`
- Nested calls the the_content filter
- How to change domain used when pinging sites
- Filter list by a unique meta value dilemma
- How to use shortcode attribute in separate function
- Is it possible to track down Actions and Filters?
- Return a custom value in a function added to an action hook
- How to filter a wordpress core function?
- Adding id and class to the search input in WordPress search form
- Multiple filters for wp_get_archive
- get_bookmarks filter not supplying query argument (wp 3.1)
- Filter and modify entry-footer link in twentyseventeen
- Function the_content not working
- Filter Posts by current Month
- Break out of wordpress filter
- Are there actions or filters I can use for Ajax calls?
- Add filter problems
- Where is the content cache when using apply_filters(‘the_content…?
- How to filter for user registration, be able to throw error message
- No ‘Access-Control-Allow-Origin’ header is present [closed]
- How to prepare WordPress Rest data for Preview Changes?
- How to validate recaptcha on comments form?
- Admin filter for product SKU?
- Contact Form 7: Make field required after checkbox is checked
- Customize title, description and focused keyword [closed]
- Is there any filter to trigger as soon as media is uploaded to post or page?
- Filter pre_get_posts does not modify Mine/All/Pending
- wp_mail works with add_action(‘save_post’, …) but not an ajax action
- add_filter with retrieve_password_message() not working in plugin, but works in functions.php
- Add a div of content within the_content after a certain block
- Can i use multiple ‘the_content’ filters?
- Is it possible to put the add-filter()-hook into a function?
- How can I return shortcode output to the top of the content?
- separate categories with comma and srounded by single quote
- Filter for when the post is updated
- Prevent add_filter being applied to wp-admin pages
- term_link filter gives less atributes
- Filter a pluggable function
- apply_filters(‘get_the_content’, $content) + Except
- Filter everything from content except output of a shortcode
- Add mime types with plugin
- Filter media upload attachment meta
- Filter have_posts()/ the_post()
- Is there a way to globallly apply esc_html( … ) to all inputs and anchors to filter out XSS markup?
- Filter wp_redirect() to stop redirect under certain condition
- Filter get_page_by_path()
- Handle multiple parameters in filter
- How to add filter in custom rss feed
- Want to use wp_get_current_user() in query filter
- Echo string in admin panel footer beside version no
- How to change default text for specific post type
- Add PHP code after title in single post pages?
- Apply wordpress filter checking category
- How To Get Search Term and Use in Function
- How to set a filter search for categories of blog posts in wordpress
- How to pass a variable between filter/action functions?
- Filter the title to only affect the_title() template function
- How can I filter the comment action links so that I can display the actions links based on user capabilities?
- Adding link options in insert/edit link dialog window
- Replace a specific URL on all apperances on the Website (Maybe a filter?)
- How to add lazy field in content endpoint using Gutenberg blocks
- Strange behaviour of REGEX in a WordPress filter (trying to suppress emtpy paragraphs)
- Modify Contextual Help
- how to use apply filter for Class?
- WordPress set featured image to first image of the post
- Modify WordPress search behaviour in backend?
- Re-order search results with posts_orderby filter and post meta value
- ‘the_content’ Filter delivers empty string with lengh (608)
- Testing requested query in pre_get_posts
- Output dynamic_sidebar_params in wp_head
- How to sort posts according to meta value?
- Converting restricted html in comments to bbcode
- What is the proper/best way to have multiple add_filter for wp-job-manager-resume
- Modify WooCommerce email shipping text value
- Using Filters To Change Page Title
- using posts_where for meta data on pre_get_posts
- can’t output gray scaled image I’ve created using add_image_size
- remove_filter excerpt_more from a plugin class
- How properly write function to filter content in a template for plugin “multiple content blocks”
- How to elect position of new item output in a dropdown when using add_filter
- Query Multiple Filters, one with Meta
- How to remove a filter that is an object method?
- Filter a custom post type by custom field in admin