1

I use a WordPress theme for a blog but some other features were asked to add such as adding post programmatically to blog. After coding it works fine but I faced a problem with wp_insert_post while using special characters. When it tries to insert a post which includes special character it gives an error. However, the theme which is on Wordpress can do it. What am I missing?

By the way it works in local even with special character

$var='ıışşüüççç'

$new_post = array(
    'post_title' => $var,
    'post_content' => $leadContent, 
    'post_status' => $postStatus,

    'post_author' => $userID,
    'post_type' => $postType,
    'post_category' => array($categoryID),
    );

    $post_id = wp_insert_post($new_post);

Thanks in advance

digging
  • 131
  • 1
  • 2
  • 9
  • will esc_html() not do it? https://developer.wordpress.org/reference/functions/esc_html/ – E3Im Nov 01 '18 at 15:13
  • @mike When i use esc_html it doest give an error but it doest save the title beause it escapes thanks – digging Nov 01 '18 at 15:25
  • does it or doesn't it – E3Im Nov 01 '18 at 15:26
  • Unfortunately,it doesnt – digging Nov 01 '18 at 15:28
  • 1
    What coallation does the database use? What character set does WP connect with to the database? Did you read [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) and follow the examples there? – h2ooooooo Nov 01 '18 at 15:36

1 Answers1

0

Ok i found the problem after too many attemps and errors.When upload a php file to server, it works fine but want to edit this file on server;the editor of DirectAdmin ,the server panel,opens the file but does not show these character in proper way.After editing and saving the file,it doesnot work anymore.I dont open php file in server editors :)

digging
  • 131
  • 1
  • 2
  • 9