Perhaps you can use the ‘wp_insert_post’ action to call wp_set_post_categories(…) after the post is stored in the database.
I think this does work in a theme’s function.php (preferably a child theme), but to me it seems better to use a plugin to change things that happen in the admin screens.
I’m confused as to what you are trying to do. Functions.php is for defining functions. It can pretty much go anywhere.
As per the CODEX page just add 'post_category' => [ array(<category id>, to your array.
Have you looked at the CODEX page for the wp_insert_post function http://codex.ww.wp.xz.cn/Function_Reference/wp_insert_post
Thread Starter
mpnzep
(@mpnzep)
@keith Driscoll
What about the subcategory?
About the Codex link:
Thanks, that may help.
Thread Starter
mpnzep
(@mpnzep)
@rod Whiteley
Yes, I´m thinking in run the function I´m intending to make into ‘functions.php’, of a child theme.
Thread Starter
mpnzep
(@mpnzep)
I think the way to set post categories, is through:
http://codex.ww.wp.xz.cn/Function_Reference/wp_set_post_terms
Thanks to all.