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

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’ ); }

conditionally load javascript & CSS for do_action() calls from plugin

And…. the answer was actually correct, if you are using the correct functions. As Milo pointed out, it’s wp_enqueue_script not scripts. add_action(‘wp_footer’, ‘print_my_script’); function print_my_script() { if(did_action(‘my_custom_action’)) { wp_enqueue_script(‘listings’); wp_enqueue_script(‘isotope’); } } Hopefully this helps someone else in need!

get_query_var not works

Your filter: function add_query_vars_filter( $vars ){ $vars[] = “getvar”; return $vars; } add_filter( ‘query_vars’, ‘add_query_vars_filter’ ); Is correct. When WordPress starts assembling the list of query variables, this function will add ‘getvar’ to the list. But then you immediately check if the variable is set before it reaches that point. The query_vars filter hasn’t happened … Read more

Sub Menu content is being duplicated

I was using the same page name for both. You can see in this snippet that I used “BCRM” and I didn’t realize it. add_submenu_page( __FILE__, ‘BCRM Customer Settings’, ‘Customer Settings’, ‘administrator’, ‘**BCRM**’, ‘bcrm_customer_settings_page’); add_submenu_page( __FILE__, ‘BCRM Form Settings’, ‘Form Settings’, ‘administrator’, ‘**BCRM**’, ‘bcrm_form_settings_page’); I changed them to BCRM_customers and BCRM_forms respectively and it is … Read more