• I’m trying to insert a post on wordpress using PHP like this:

    $insertar = array();
      $insertar['post_title'] = 'Titulo';
      $insertar['post_content'] = 'contenido';
      $insertar['post_status'] = 'publish';
      $insertar['post_author'] = 1;
      $insertar['post_category']= array(1);
    
    wp_insert_post($insertar);

    The problem comes when the string contains special characters. (á, é, í, ó, ú, ? …), does not insert into MySQL.

    Any solution?, Thanks.

Viewing 1 replies (of 1 total)
  • A simple php function can solve this problem utf8_encode()

    $insertar[‘post_title’] =utf8_encode( ‘Tituloáéíóú?’);

Viewing 1 replies (of 1 total)
  • The topic ‘wp_insert_post and special characters’ is closed to new replies.