How to insert post from external php file?

The best way to do this is, write the above code in your themes function.php. In this way you will have access to all the WP inbuilt functions, hooks, actions etc. Then use Cronjob Scheduler plugin – https://wordpress.org/plugins/cronjob-scheduler/ to run your function periodically.

insert category from form in a post

You need to create the category first, then add it to the post: $my_post = array(); $my_post[‘post_author’] = $userid; $my_post[‘post_title’] = $name; $my_post[‘post_name’] = str_replace(‘ ‘, ‘-‘, $name); $cat_id = wp_create_category($_POST[‘postcats’], 0); // we create the category and we get the ID, the 0 is for no parent category $my_post[‘post_category’] = array($cat_id);//this value is an … Read more

How can I automatically add a post with Latin characters?

htmlspecialchars() only converts &, “, ‘, < and >. To also convert (encode, really) accented characters, you need to use htmlentities(), and depending on the rest of your setup you may also have to specify which encoding to use. So: $content = htmlspecialchars( $text, ENT_QUOTES|ENT_SUBSTITUTE, ‘UTF-8’ ); (Substitute ‘ISO-8859-1’ for ‘UTF-8’ if necessary, though it … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)