[wp-hackers] Fatal error: Call to undefined function wp_insert_category() in ....

Dion Hulse (dd32) wordpress at dd32.id.au
Fri Apr 6 00:36:46 UTC 2012


3 points.

1. Windows paths need to be written as F:\\inetpath\\ or F:/inetpath/ etc
2. Always include wp-load.php instead of wp-config or wp-blog-header
for stand along scripts
3. wp_insert_category() is an admin function, you must also load the
administrative functions by including wp-admin/admin.php


On 6 April 2012 10:27, Haluk Karamete <halukkaramete at gmail.com> wrote:
> I run the following function in a standalone php file.
>
> $cat_defaults = array(
>  'cat_name' => 'Religion',
>  'category_description' => '',
>  'category_nicename' => '',
>   'category_slug' => 'Religion',
>  'category_parent' => '' );
>
> $my_cat_id = wp_insert_category( $cat_defaults );
>
> and this comes back with
>
> Fatal error: Call to undefined function wp_insert_category() in ....
>
>
> The php file has the following on top!
>
> <?php
>
> error_reporting (E_ALL);
>
> $which_wordpress = "/ic2";
>
> $full_path_to_wp_header = "F:\inetpub\wwwroot\whatever\wp-blog-header.php";
>
> include ($full_path_to_wp_header);
>
> define('WP_USE_THEMES', false);
>
> echo bloginfo();  //this DOES report the blog title! I thought this was the
> proof that whole wordpress she-bang loaded! I guess I'm wrong!
>
> ?>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list