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’
- Function to return true if current page has child pages
- List of all theme customizer control types?
- Get author full name
- Integrating WordPress to my website, while keeping my own authentication system
- Remove/unset options field from backend Settings->General?
- Display posts by month
- How to preserve PHP modifications while upgrading WordPress?
- Removing jQuery migrate and working with dependencies
- Load post content into iframe
- is there a simple way to list every templates / php files used to generate a specific page?
- wp_customize_image_control default value
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- WordPress Customizer: How can you have multiple active callbacks on one control?
- Edit postmeta when user changes user role?
- Authenticating to WordPress, using my own authentication two-factor system
- How to add default images into theme customizer image control?
- WordPress Ajax Data problem
- there’s a way to include a minimal WP for check only the current user, its roles (caps?) and then release/free it?
- Remove all nav menu classes ( but keep useful ones… )
- Add attribute / custom attribute to product in woocommerce
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Blank space at beginning of tag?
- Locating Global Variables
- Displaying theme options in css
- Set post title based on first h2 element in the content section
- Creating bulk posts with Youtube videos
- An extra ‘ is displayed in the title
- Hide wordpress field if data is empty in post!
- Setting custom canonical urls
- Only show search results with if current date is between two dates?
- database interactions using OOP
- WordPress blog post url on category page
- Changing layout with wp_customise
- Extending the WP_Widget_Text class
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- filter default query to show just selected level of child pages in wordpress
- Trying to build simple deposit code that hooks into woocommerce
- user_profile_update_errors hook not executing
- Saving and Restoring a Canvas on A Individual User Basis
- Extend plugin Class through functions.php
- Change title only in dynamic page
- Menu jumping when calling it via PHP
- Modify custom field input data before creating a new post
- Output custom field value to post string
- Need help enqueueing webfonts
- Custom Background by Page IDs
- Change order of custom submenu link in WP Admin?
- Underscore – Self hosted fonts
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Run str_replace on title and save the output to a custom field
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- str_replace with the_content is not working
- How to create a field in customize and show that in header.php?
- change title page on search result
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- woocommerce related product title length
- Set cookie for visitor
- Display movies that apear this day next
- is_user_logged_in returning nothing on custom page
- Customize field names in backend profile edit page through function.php [duplicate]
- how to add datas in taxonomy to post with wp_insert_post
- Insert content into head tag with function
- How do I choose not to display the title header on a specific page?
- Change permalink structure specific category
- Array data not saving to specified sections. How to make seting independantly?
- I need to display posts in subcategory beside posts in main category
- Integrate otp in my custom singup form
- how to replace h1 entry title with h2 in category pages only
- How do I know if the user is a customer?
- How to block specific user id in custom login form?
- I want to fusion the product columns in email table order
- Add a new view on the Woocommerce account page
- How do I add a predefined class to a custom html element?
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- How to separate the taxonomies list from the form so that editing taxonmies is the same as pages and posts?
- Redirect user role to a specific page on login in a multisite network?
- Add custom attribute to product’s HTML to woocommerce cart page
- Autoloading Classes in Plugins
- Remove node from multisites?
- Put a span class in the shortened product title
- custom field – changing an element or background of id div – different versions not working
- How to get php file based on URL in WordPress
- Use custom get results query to show posts WordPress
- How can I show only if custom field has content [closed]
- media-uploader insert into post is not inserting
- How to show all of aspecific post type that has taxonomy and a specific term
- How to hide something from custom home page with php code?
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- Display a list of users with avatar filterable with alphabets
- How can I add more code to this?
- How does one programmatically manage posts from a external php script?
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- New to WordPress & Freelancing [closed]
- hello can you advise how to fix the error?
- Add multiple HTML attributes to an Elementor button
- Getting a specific “title for a section” only on Startpage?