You are correct, you need to use str_replace
. See details here
So the correct code would be:
$postData = array(
'post_title' => str_replace('_', ' ', $attachment->post_title),
'post_type' => 'post',
'post_content' => $image_tag,
'post_category' => array('0'),
'post_status' => 'publish'
);
Related Posts:
- String replace WordPress Site Title
- Customized title tag for each page in pagination?
- Echo title attribute php
- Display tab title as ‘blog tagline | blog title’
- How to check if a meta value has already been assigned to any user?
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- filter default query to show just selected level of child pages in wordpress
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Trying to build simple deposit code that hooks into woocommerce
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Add New User, extra fields which are required?
- Remove the first 5 characters of the_title and orderby that
- user_profile_update_errors hook not executing
- Send an email to specific adress when button is clicked?
- Customizer: active_callback and sanitize_callback incompatibility?
- Saving and Restoring a Canvas on A Individual User Basis
- Redirect specific user role to specific site after login?
- Send multiple attachments with wp_mail in PHP
- WordPress admin pointers tour bug?
- custom url rewrite for wordpress
- Extend plugin Class through functions.php
- Change title only in dynamic page
- Display custom post type title as text if post thumbnail is not available
- How to add a do_action on refreshing of WP customizer?
- Customize position of social icons in upme plugin [closed]
- Weird 404 URL Problem – domain name being placed at end of urls
- How to get the value of input hidden html from text editor to custom page template?
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- Menu jumping when calling it via PHP
- Output Video Download Link in template
- Modify custom field input data before creating a new post
- Output custom field value to post string
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Media Upload , file name changed automatically
- Replace shortcode in substring
- Custom posts in different columns style
- Need help enqueueing webfonts
- need help with existing code showing subpages
- How do I add a custom css to all posts without affecting homepage css? [closed]
- how to show only specific category for a template
- Custom Background by Page IDs
- Advanced Custom Fields not displaying
- How to get private property in parent class into extended class?
- How to obtain the current website URL in my theme?
- What exactly do this function declared into functions.php file of a WP theme?
- Change page title from page using php via php executed from page/post itself
- “operation successful” message
- Exclude posts with specific metadata from search?
- Change order of custom submenu link in WP Admin?
- Underscore – Self hosted fonts
- Reduce size of responsive title
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Hook called before text widget save
- Run str_replace on title and save the output to a custom field
- Add data-id attribute to child page links
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Warning: Illegal string offset on theme options page [closed]
- Clickable image link sends people to wrong URL
- customize wordpress database error page
- Display Youtube Time Automate from Key
- How to fix this PHP warning in WP-Admin after upgrading to 3.1.2?
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Create page template via functions.php?
- str_replace with the_content is not working
- How to create a field in customize and show that in header.php?
- Where is the PHP code generating an element?
- Basic wpdb update question
- How to include custom PHP file both in header and footer files
- change title page on search result
- Check class_exists before class definition / Doxygen problem
- Ajax search shows all results when user empties input?
- Extract links from content
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- woocommerce related product title length
- Delete or edit postmeta with specific meta_key?
- Integrating Yii2 and WordPress
- List post by title length
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- Custom Registration username_exists / email_exists
- Need help with pagination
- Split site title and apply different classes
- After disabling WPML multi currency, the currency is still handled by the WPML
- How do i wrap woocomerce attribute in list?
- get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
- PHP Helper Class to create shortcodes
- Update if post with specific title exists
- Reusable code that I can store in the function.php and apply to other templates as need. Dry Code
- Is it possible to add a custom page to a free WordPress site? [closed]
- Is there a hack for using is_page() within the function.php file?
- save metabox with new values _wp_page_template
- How to Fix an Archive.php That Displays All Posts?
- List of Events with Multiple Dates: Only NEXT Date
- Set cookie for visitor
- Assign Custom classes to every Excerpt
- Make next post button link to random post
- pass html code to worpdress
- pagination broken – clicking next displays “page not found”