//Search by tags
$query = new WP_Query( 'tag=old' );
// Then update post titles
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
//check if title have "a new"
if(strpos(get_the_title(),'a new') !== false) :
$post = array(
'ID'=> get_the_id(),
'post_title'=> str_replace('a new','an old',get_the_title())
);
// Update the post into the database
wp_update_post( $post );
endif;
}
}
Related Posts:
- Search/Replace for editor in HTML-mode
- Search results with custom loop don’t update when paged
- Making a list of post tags in string
- Related Tags Concept
- Default WP search excluding specific characters, is it possible?
- How to add additional search terms (e.g. synonyms) to the search?
- Search by keywords with boolean operators
- Redirect All Search Links Containing – to + on WordPress
- Generate list of tags from search results
- Search posts by Tag
- Strip HTML Tags From Search Results
- Include results with tags relevant to the search keyword with JSON rest API v2
- Displaying a list of tags in my archives page
- Return All Tags from Search Result in Separate List
- Redirect wordpress search query if its a tag
- WordPress Search by tags
- Creating a search with tag variable also added for more detailed results
- Search & Replace trailing strings
- How to display articles based on composed tag
- Make search result returned only from tags! [duplicate]
- Search with multiple selects that include tags
- Need help to be able to searching by tag and title
- how to limit search to post titles?
- How does WordPress search work behind the scenes?
- Remove some pages from search
- WordPress blog with 30 000 posts: poor search performance
- How do I filter the search results order?
- Link to search page without search parameter
- Do I need to sanitize WordPress search query?
- Neither the_excerpt() nor the_content() works properly?
- Add custom parameters to JSON API search query?
- How to allow user to perform search by more than one tag
- Is there a way to do multiple ordering on a multiple meta_query?
- How to stop _wpnonce and _wp_http_referer from appearing in URL
- Return all Tags from search results
- Does WP search natively return results sorted by type (post, post type, page, category…)?
- intellisense in wp search
- Search result conditonal tag
- Get search term not on searh results page?
- Search Result from another wordpress website
- Remove WHERE conditions from search query
- Show posts on a page based on a category and tag(s)
- Change default search URL slug in wordpress with Custop Post Type as Search target
- How to conditionally pass a parameter to wordpress search to limit post types?
- Is there a quick way to find out what posts haven’t been tagged?
- Change WordPress search Permalink structure
- Media searching ignored
- Use created page as search results page and custom template
- How do I search dynamically created content?
- Post 2 Post Site Search
- Using search.php without a ‘s’ field in searchform.php
- Search queries don’t seem to work?
- Array_search ignoring the first element [closed]
- Add Icon to Placeholder Text in Search Form
- Unexpected esc_html and esc_attr behaviour
- Search Results No Link
- Search for two strings in WP search
- Sort search results by Custom Field
- Order search results by category
- Search URL parameters query [duplicate]
- How to build an advanced search form by post type?
- Should I create a parent page with no content? [closed]
- Why WP_Query’s ‘s’=>’keyword’ searches only for ‘post_title’ and why not ‘post_content’?
- adding more text to a query string
- Independent search tool that returns exact match of a post title
- Search using WP_Query
- When clicking on submit from my searchform it takes me to home.php
- My default search is not working
- Dashboard search function doesn’t work well
- My search form finds page 1 results but shows “error 404 page not found” on pages 2 on or clicking next
- twentyeleven theme: Where is the code that handles moving the search bar on resize?
- Search custom posts by meta key in admin
- search form for custom fields
- Search within the current page
- What are the available options for “Name” in WP search?
- how to make search with two input boxes
- WordPress search with more input fields?
- WordPress search not able to find the category
- Editing a Search Form
- how to prevent the spam on search function?
- I have dynamic title tag in my wordpress but seo analyst show “No title Tag found error”?
- limit the number of searches
- How can I prevent the Search Results Page from changing title?
- Problem with site’s search results “Read More” link?
- WordPress search for specific Post Type
- Custom search page and url in multilanguage
- Search Page: activate html code if the tag is on the page
- Custom search results
- Custom display for homepage, tag and author pages
- Make the title and […] clickable in result search
- Multiselect value in wp_query
- Custom search by several options send on form not works
- wp_redirect and search engine bots
- Strip the + symbol from the_search_query
- Putting Text in the Search Box. eg- “Search My Site” [closed]
- How to remove search bar from the blog post
- How make Autocomplete with wp_query in post_type attachment
- Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
- WordPress Search – Reject partial matches
- Wp query search built out of 4 terms?