wp_insert_category() setting the ‘cat_ID’ gives not array error

Ok here is the solution I found: You are not meant to set IDs when creating new objects like categories. Instead I created the parent categories first using something like $my_cat = array( ‘cat_name’ => ‘Community News & Views’, ‘category_nicename’ => ‘news’, ‘taxonomy’ => ‘category’ ); $my_cat_id = wp_insert_category($my_cat); In a second step I create … Read more

How to create custom tables in WordPress using my own plugin?

Creating Tables with plugin This page shows how to work with tables in plugins. Example on that page includes table creation during installation of plugin. But it can be dynamically used also to create table. See below. if(isset($_POST[‘create’]) { $table_name=$_POST[‘table_name’]; Note : don’t use – in variable names. global $wpdb; $sql = “CREATE TABLE $table_name … Read more

Including the necessary functions for a custom ajax registration form

Here is a basic setup that I use for AJAX with WordPress. instead of loading wp-load.php on a separate php file; just use WordPress default method for AJAX calls. This allows you to also filter function calls from Javascript through a switch. I also added a quick example for wp_localize_script. <?php add_action(‘wp_enqueue_scripts’, ‘YOUR_NAME_scripts’); //back end … Read more

Correct check for any admin page with editor

Inspect the global variable $pagenow, and use post_type_supports() to find post types with an editor: function has_post_editor() { global $pagenow; if ( empty ( $pagenow ) ) return FALSE; if ( ! in_array( $pagenow, array ( ‘post-new.php’, ‘post.php’ ) ) ) return FALSE; return post_type_supports( get_current_screen()->post_type, ‘editor’ ); }

Unable to override pluggable function wp_mail

I think this line: namespace MailDemo; is the reason for you problems. You define your custom wp_mail() function within this namespace, so it looks like you’re trying to override the function: \MailDemo\wp_mail() but not the pluggable function: \wp_mail() Try to remove the namespace setup and see what happens. Another way around this would be to … Read more