0

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.