Replace Underscore (_) on Space ( )

I use the plugin "Auto Post With Image Upload" For example I load an image with name "Image_Name" then plugin creates a post with name "Image_Name"

Now the question: How to remove Underscore (_) in post title Tell me "where to dig"? I know that there are such a function "str_replace". Where apply it?

Here is a piece of code:

$postData = array(
    'post_title' = $attachment-post_title,
    'post_type' = 'post',
    'post_content' = $image_tag,
    'post_category' = array('0'),
    'post_status' = 'publish'
);

P.S. I not quite understand php

Topic underscore title php customization Wordpress

Category Web


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'
);

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.