Hello,
I've tried to run a PHP file created by me.
It has one purpose only: to set some categories to an existing post.
I use (wrongly, it seems) this function: wp_set_post_categories
Cand you plese guide me into one solution?
See bellow my (not working) PHP file. I've put it in the Plugins folder, to allow me to run admin.php.
<?php
$cats = array ("cat1","cat3","cat2"); //these categories exist
$admin = realpath(dirname(__FILE__) . '/../..'.'/wp-admin'); //this line works, no erros given
chdir($admin); //this line works, no erros given
require_once $admin . '/admin.php'; //this line works, no erros given
$id = intval(63); //I use this function to make sure it's an integer value
wp_set_post_categories($id, $cats); //you got it, this doesn't work
echo 'I got until here.'; //This text is printed on the screen
?>
Any ideas welcome.