Jump to content

Search the Community

Showing results for tags 'wp_insert_post'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi all I am having problems with french characters when using a custom function to upload posts from a database into wordpress Firstly here is my code: //This gets the values that is sent to the class to create post <?php require_once('wp-content/plugins/PostAdder/index.php'); try { $host = 'localhost'; //$dbname = 'wordpress'; $dbname = 'HotelWifi'; $user = 'root'; $pass = ''; $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8') ); } catch(PDOException $e) { echo $e->getMessage(); } $STH = $DBH->query('select * from activepropertylist'); $STH->setFetchMode(PDO::FETCH_ASSOC); while($row = $STH->fetch()) { $hotelname = ucwords(utf8_decode($row['Name'])); $city = $row['City']; $STH1 = $DBH->query('select * from wp_terms WHERE name = "' . $city . '"'); $STH1->setFetchMode(PDO::FETCH_ASSOC); while($row1 = $STH1->fetch()) { $cat = $row1['term_id']; } $tcat = array($cat); post_a_newhotel($hotelname, $tcat) ; } ?> // this is the function that fills the class and calls the wp_insert_post function <?php /* Plugin Name: POstHotel Plugin URI: http://www.hotelwifiscore.com Description: Creates post from supplied data Version: 1 Author: davegrix Author URI: http://www.hotelwifiscore.com */ require_once('wp-load.php'); class wm_mypost { var $post_title; var $post_category; } function post_a_newhotel($title, $post_cat) { if (class_exists('wm_mypost')) { $myclass = new wm_mypost(); } else { class wm_mypost { var $post_title; var $post_category; } } // initialize post object $wm_mypost = new wm_mypost(); // fill object $wm_mypost->post_title = utf8_decode($title); $wm_mypost->post_category = $post_cat; $wm_mypost->post_status = 'publish'; array_walk_recursive($wm_mypost, function (&$value) { $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8'); } ); wp_insert_post($wm_mypost); } ?> The string I am having problems with is 'Best Western Premier Hôtel L'Aristocrate' The result stored using the above is: Best Western Premier H?tel L'Aristocrate database is set to utf8_general_ci Can anyone shine any light on what to do?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.