get categories the post was in and just been removed from

save_post runs too late to do what you are trying to do. That hook fires after the post and related meta data are stored. The category has already been removed at that point, and WordPress keeps no record. You will need to hook into the save process earlier, perhaps pre_post_update: add_action( ‘pre_post_update’, function($post_ID,$data) { var_dump($post_ID,$data); … Read more

WordPress Shop and restricting products and categories for some users/groups

Essentially, you need: A global role-category relationship list, and/or… A per-user category list For per-user categories, hook onto the relevant profile actions: show_user_profile & edit_user_profile for displaying the field (use wp_terms_checklist()) personal_options_update & edit_user_profile_update for saving the data For the role-category data, use an options page. Loop over all roles ($wp_roles->roles) with a term checklist … Read more

Alphabetize all but one category

Add an else to the condition along with adding the excluded category id in the is_category() call. You will also need to include/exclude that particular category depending on the condition that is true: NOTE: you probably want to avoid using query_posts and use WP_Query() Reference here <?php if (is_category(15)) { $posts = query_posts($query_string . ‘&orderby=date&order=asc&cat=15’); … Read more

How to add a new child category via an SQL statement?

Insert taxonomy terms via a raw SQL query is hard and discouraged, use the core wp_insert_term function, instead. Assuming you have an array of continent/countries terms: $countries_list = array( ‘Europe’ => array( ‘Austria’, ‘France’, ‘Italy’, ‘Germany’, ‘Spain’, ‘United Kingdom’ ) ); foreach ( $countries_list as $continent => $countries ) { // get term object for … Read more