Title: Exclude doesn&#8217;t work
Last modified: April 8, 2020

---

# Exclude doesn’t work

 *  Resolved [Wyciokazz](https://wordpress.org/support/users/wyciokazz/)
 * (@wyciokazz)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-doesnt-work-3/)
 * I’ve tested excluded categories, and it doesn’t work as i see i’m always get 
   Post Category as 1
 * PHP Code
 *     ```
       			$s2_taxonomies = apply_filters( 's2_taxonomies', array( 'category' ) );
       			$post_cats     = wp_get_post_categories($post->ID);
       			// Fail gracefully if we have a post but no category assigned or a taxonomy error
       			if ( is_wp_error( $post_cats ) || ( empty( $post_cats ) && 'post' === $post->post_type ) ) {
       				return $post;
       			}
   
       			$wfile = fopen("log.txt", "a+");
       			fclose($wfile);		
       			$myfile = fopen("log.txt", "a+") or die("Unable to open file!");
       			$date = new DateTime(null, new DateTimeZone('Europe/Vilnius'));
       			$txt = $date->format('Y-m-d H:i:s');	
       			$txt .= "\n--- POST INFO ----\n";	
       			$txt .= print_r($post, true);			
       			$txt .= "\n--- S2 Options ----\n";	
       			$txt .= print_r($this->subscribe2_options, true);					
   
       			$check = false;
       			// is the current post assigned to any categories
       			// which should not generate a notification email?
       			$excludes = explode( ',', $this->subscribe2_options['exclude'] );
       			$txt .= "\nPOST CATS \n";
       			$txt .= print_r($post_cats, true);		
       			$txt .= "\nEXCLUDED CATS \n";
       			$txt .= print_r($excludes, true);					
       			foreach ($excludes  as $cat ) {
       				$txt .= "\n FOREACH AS excludes as cat \n";
       				$txt .= "CAT ID:".$cat."\n";
   
       				if ( in_array( (int) $cat, $post_cats, true ) ) {
       					$check = true;
       					$txt .= "\nIN EXCLUDE\n";
       				} else {
       					$txt .= "\nNOT IN EXCLUDE\n";
       				}
       			}	
       			$txt .= "\n\n\n";
       			fwrite($myfile, $txt);
       			fclose($myfile);
       ```
   
 * I wrote some debug in log file
 *     ```
       2020-04-09 00:17:51
       --- POST INFO ----
       WP_Post Object
       (
           [ID] => 2013
           [post_author] => 1
           [post_date] => 2020-04-09 00:17:51
           [post_date_gmt] => 2020-04-08 21:17:51
           [post_content] => <!-- wp:paragraph -->
       <p>BLABLABLA</p>
       <!-- /wp:paragraph -->
           [post_title] => Test1
           [post_excerpt] => 
           [post_status] => publish
           [comment_status] => closed
           [ping_status] => closed
           [post_password] => 
           [post_name] => test1
           [to_ping] => 
           [pinged] => 
           [post_modified] => 2020-04-09 00:17:51
           [post_modified_gmt] => 2020-04-08 21:17:51
           [post_content_filtered] => 
           [post_parent] => 0
           [guid] => https://karolisgecas.com/?p=2013
           [menu_order] => 0
           [post_type] => post
           [post_mime_type] => 
           [comment_count] => 0
           [filter] => raw
       )
   
       --- S2 Options ----
       Array
       (
           [autosub] => no
           [newreg_override] => no
           [wpregdef] => no
           [autoformat] => html_excerpt
           [show_autosub] => no
           [autosub_def] => no
           [comment_subs] => no
           [comment_def] => no
           [one_click_profile] => no
           [bcclimit] => 1
           [admin_email] => subs
           [tracking] => 
           [s2page] => 0
           [stylesheet] => yes
           [embed] => no
           [pages] => no
           [password] => no
           [stickies] => no
           [private] => no
           [email_freq] => never
           [cron_order] => desc
           [compulsory] => 1
           [exclude] => 35
           [sender] => blogname
           [reg_override] => 
           [show_meta] => 0
           [show_button] => 1
           [ajax] => 0
           [widget] => 1
           [counterwidget] => 0
           [s2meta_default] => 0
           [barred] => 
           [exclude_formats] => 
           [mailtext] => {BLOGNAME} has posted a new item, '{TITLE}'
   
       {POST}
   
       You may view the latest post at
       {PERMALINK}
   
       You received this e-mail because you asked to be notified when new updates are posted.
       Best regards,
       {MYNAME}
       {EMAIL}
           [notification_subject] => [{BLOGNAME}] {TITLE}
           [confirm_email] => {BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below:
   
       {LINK}
   
       If you did not request this, please feel free to disregard this notice!
   
       Thank you,
       {MYNAME}.
           [confirm_subject] => [{BLOGNAME}] Please confirm your request
           [remind_email] => This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete.
   
       If you wish to complete your subscription please click on the link below:
   
       {LINK}
   
       If you do not wish to complete your subscription please ignore this email and your address will be removed from our database.
   
       Regards,
       {MYNAME}
           [remind_subject] => [{BLOGNAME}] Subscription Reminder
           [js_ip_updater] => 
           [version] => 10.32
           [dismiss_sender_warning] => 0
       )
   
       POST CATS 
       Array
       (
           [0] => 1
       )
   
       EXCLUDED CATS 
       Array
       (
           [0] => 35
       )
   
        FOREACH AS excludes as cat 
       CAT ID:35
   
       NOT IN EXCLUDE
   
       2020-04-09 00:18:09
       --- POST INFO ----
       WP_Post Object
       (
           [ID] => 2015
           [post_author] => 1
           [post_date] => 2020-04-09 00:18:09
           [post_date_gmt] => 2020-04-08 21:18:09
           [post_content] => <!-- wp:paragraph -->
       <p>BULBULBUL</p>
       <!-- /wp:paragraph -->
           [post_title] => Test2
           [post_excerpt] => 
           [post_status] => publish
           [comment_status] => closed
           [ping_status] => closed
           [post_password] => 
           [post_name] => test2
           [to_ping] => 
           [pinged] => 
           [post_modified] => 2020-04-09 00:18:09
           [post_modified_gmt] => 2020-04-08 21:18:09
           [post_content_filtered] => 
           [post_parent] => 0
           [guid] => https://karolisgecas.com/?p=2015
           [menu_order] => 0
           [post_type] => post
           [post_mime_type] => 
           [comment_count] => 0
           [filter] => raw
       )
   
       --- S2 Options ----
       Array
       (
           [autosub] => no
           [newreg_override] => no
           [wpregdef] => no
           [autoformat] => html_excerpt
           [show_autosub] => no
           [autosub_def] => no
           [comment_subs] => no
           [comment_def] => no
           [one_click_profile] => no
           [bcclimit] => 1
           [admin_email] => subs
           [tracking] => 
           [s2page] => 0
           [stylesheet] => yes
           [embed] => no
           [pages] => no
           [password] => no
           [stickies] => no
           [private] => no
           [email_freq] => never
           [cron_order] => desc
           [compulsory] => 1
           [exclude] => 35
           [sender] => blogname
           [reg_override] => 
           [show_meta] => 0
           [show_button] => 1
           [ajax] => 0
           [widget] => 1
           [counterwidget] => 0
           [s2meta_default] => 0
           [barred] => 
           [exclude_formats] => 
           [mailtext] => {BLOGNAME} has posted a new item, '{TITLE}'
   
       {POST}
   
       You may view the latest post at
       {PERMALINK}
   
       You received this e-mail because you asked to be notified when new updates are posted.
       Best regards,
       {MYNAME}
       {EMAIL}
           [notification_subject] => [{BLOGNAME}] {TITLE}
           [confirm_email] => {BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below:
   
       {LINK}
   
       If you did not request this, please feel free to disregard this notice!
   
       Thank you,
       {MYNAME}.
           [confirm_subject] => [{BLOGNAME}] Please confirm your request
           [remind_email] => This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete.
   
       If you wish to complete your subscription please click on the link below:
   
       {LINK}
   
       If you do not wish to complete your subscription please ignore this email and your address will be removed from our database.
   
       Regards,
       {MYNAME}
           [remind_subject] => [{BLOGNAME}] Subscription Reminder
           [js_ip_updater] => 
           [version] => 10.32
           [dismiss_sender_warning] => 0
       )
   
       POST CATS 
       Array
       (
           [0] => 1
       )
   
       EXCLUDED CATS 
       Array
       (
           [0] => 35
       )
   
        FOREACH AS excludes as cat 
       CAT ID:35
   
       NOT IN EXCLUDE
       ```
   

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Matt Robinson](https://wordpress.org/support/users/mattyrob/)
 * (@mattyrob)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-doesnt-work-3/#post-12649212)
 * [@wyciokazz](https://wordpress.org/support/users/wyciokazz/)
 * Are you using the Block Editor by any chance? I suspect you’d find this works
   fine in the Classic Editor.
 * It may be linked to this core bug:
    [https://core.trac.wordpress.org/ticket/45114](https://core.trac.wordpress.org/ticket/45114)
 *  Thread Starter [Wyciokazz](https://wordpress.org/support/users/wyciokazz/)
 * (@wyciokazz)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-doesnt-work-3/#post-12649229)
 * Tested, on classic editor. Same error
 *     ```
       2020-04-09 10:38:37
       --- POST INFO ----
       WP_Post Object
       (
           [ID] => 2018
           [post_author] => 1
           [post_date] => 2020-04-09 10:38:37
           [post_date_gmt] => 2020-04-09 07:38:37
           [post_content] => 
           [post_title] => Testas040901
           [post_excerpt] => 
           [post_status] => publish
           [comment_status] => closed
           [ping_status] => closed
           [post_password] => 
           [post_name] => testas040901
           [to_ping] => 
           [pinged] => 
           [post_modified] => 2020-04-09 10:38:37
           [post_modified_gmt] => 2020-04-09 07:38:37
           [post_content_filtered] => 
           [post_parent] => 0
           [guid] => https://karolisgecas.com/?p=2018
           [menu_order] => 0
           [post_type] => post
           [post_mime_type] => 
           [comment_count] => 0
           [filter] => raw
       )
   
       --- S2 Options ----
       Array
       (
           [autosub] => no
           [newreg_override] => no
           [wpregdef] => no
           [autoformat] => html_excerpt
           [show_autosub] => no
           [autosub_def] => no
           [comment_subs] => no
           [comment_def] => no
           [one_click_profile] => no
           [bcclimit] => 1
           [admin_email] => subs
           [tracking] => 
           [s2page] => 0
           [stylesheet] => yes
           [embed] => no
           [pages] => no
           [password] => no
           [stickies] => no
           [private] => no
           [email_freq] => never
           [cron_order] => desc
           [compulsory] => 1
           [exclude] => 35
           [sender] => blogname
           [reg_override] => 
           [show_meta] => 0
           [show_button] => 1
           [ajax] => 0
           [widget] => 1
           [counterwidget] => 0
           [s2meta_default] => 0
           [barred] => 
           [exclude_formats] => 
           [mailtext] => {BLOGNAME} has posted a new item, '{TITLE}'
   
       {POST}
   
       You may view the latest post at
       {PERMALINK}
   
       You received this e-mail because you asked to be notified when new updates are posted.
       Best regards,
       {MYNAME}
       {EMAIL}
           [notification_subject] => [{BLOGNAME}] {TITLE}
           [confirm_email] => {BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below:
   
       {LINK}
   
       If you did not request this, please feel free to disregard this notice!
   
       Thank you,
       {MYNAME}.
           [confirm_subject] => [{BLOGNAME}] Please confirm your request
           [remind_email] => This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete.
   
       If you wish to complete your subscription please click on the link below:
   
       {LINK}
   
       If you do not wish to complete your subscription please ignore this email and your address will be removed from our database.
   
       Regards,
       {MYNAME}
           [remind_subject] => [{BLOGNAME}] Subscription Reminder
           [js_ip_updater] => 
           [version] => 10.32
           [dismiss_sender_warning] => 0
       )
   
       POST CATS 
       Array
       (
           [0] => 1
       )
   
       EXCLUDED CATS 
       Array
       (
           [0] => 35
       )
   
        FOREACH AS excludes as cat 
       CAT ID:35
   
       NOT IN EXCLUDE
   
       2020-04-09 10:39:00
       --- POST INFO ----
       WP_Post Object
       (
           [ID] => 2020
           [post_author] => 1
           [post_date] => 2020-04-09 10:39:00
           [post_date_gmt] => 2020-04-09 07:39:00
           [post_content] => 
           [post_title] => Testas040902
           [post_excerpt] => 
           [post_status] => publish
           [comment_status] => closed
           [ping_status] => closed
           [post_password] => 
           [post_name] => testas040902
           [to_ping] => 
           [pinged] => 
           [post_modified] => 2020-04-09 10:39:00
           [post_modified_gmt] => 2020-04-09 07:39:00
           [post_content_filtered] => 
           [post_parent] => 0
           [guid] => https://karolisgecas.com/?p=2020
           [menu_order] => 0
           [post_type] => post
           [post_mime_type] => 
           [comment_count] => 0
           [filter] => raw
       )
   
       --- S2 Options ----
       Array
       (
           [autosub] => no
           [newreg_override] => no
           [wpregdef] => no
           [autoformat] => html_excerpt
           [show_autosub] => no
           [autosub_def] => no
           [comment_subs] => no
           [comment_def] => no
           [one_click_profile] => no
           [bcclimit] => 1
           [admin_email] => subs
           [tracking] => 
           [s2page] => 0
           [stylesheet] => yes
           [embed] => no
           [pages] => no
           [password] => no
           [stickies] => no
           [private] => no
           [email_freq] => never
           [cron_order] => desc
           [compulsory] => 1
           [exclude] => 35
           [sender] => blogname
           [reg_override] => 
           [show_meta] => 0
           [show_button] => 1
           [ajax] => 0
           [widget] => 1
           [counterwidget] => 0
           [s2meta_default] => 0
           [barred] => 
           [exclude_formats] => 
           [mailtext] => {BLOGNAME} has posted a new item, '{TITLE}'
   
       {POST}
   
       You may view the latest post at
       {PERMALINK}
   
       You received this e-mail because you asked to be notified when new updates are posted.
       Best regards,
       {MYNAME}
       {EMAIL}
           [notification_subject] => [{BLOGNAME}] {TITLE}
           [confirm_email] => {BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below:
   
       {LINK}
   
       If you did not request this, please feel free to disregard this notice!
   
       Thank you,
       {MYNAME}.
           [confirm_subject] => [{BLOGNAME}] Please confirm your request
           [remind_email] => This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete.
   
       If you wish to complete your subscription please click on the link below:
   
       {LINK}
   
       If you do not wish to complete your subscription please ignore this email and your address will be removed from our database.
   
       Regards,
       {MYNAME}
           [remind_subject] => [{BLOGNAME}] Subscription Reminder
           [js_ip_updater] => 
           [version] => 10.32
           [dismiss_sender_warning] => 0
       )
   
       POST CATS 
       Array
       (
           [0] => 1
       )
   
       EXCLUDED CATS 
       Array
       (
           [0] => 35
       )
   
        FOREACH AS excludes as cat 
       CAT ID:35
   
       NOT IN EXCLUDE
       ```
   
 *  [Matt Robinson](https://wordpress.org/support/users/mattyrob/)
 * (@mattyrob)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-doesnt-work-3/#post-12649435)
 * [@wyciokazz](https://wordpress.org/support/users/wyciokazz/)
 * Are you using the Classic Editor plugin or just the Block Editors Classic block?
 * I cannot reproduce this error using the Classic Editor and you can work around
   the issue in the Block Editor by manually saving the post data before you publish.
 *  Thread Starter [Wyciokazz](https://wordpress.org/support/users/wyciokazz/)
 * (@wyciokazz)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-doesnt-work-3/#post-12649491)
 * I’m using this method.
 * [https://ithemes.com/how-to-use-classic-editor-wordpress-5-0/](https://ithemes.com/how-to-use-classic-editor-wordpress-5-0/)
 *  [Matt Robinson](https://wordpress.org/support/users/mattyrob/)
 * (@mattyrob)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-doesnt-work-3/#post-12649663)
 * [@wyciokazz](https://wordpress.org/support/users/wyciokazz/)
 * There are two options on there, it mentions using the Classic Block or a plugin
   which makes the editor look different. Which f the 2 did you use for the Classic
   test? Did you Add Block and Classic? If so that’s not what I mean by the Classic
   Editor.
 *  Thread Starter [Wyciokazz](https://wordpress.org/support/users/wyciokazz/)
 * (@wyciokazz)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-doesnt-work-3/#post-12650079)
 * I didn’t use any additional plugins.
 *  [Matt Robinson](https://wordpress.org/support/users/mattyrob/)
 * (@mattyrob)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-doesnt-work-3/#post-12651383)
 * [@wyciokazz](https://wordpress.org/support/users/wyciokazz/)
 * That basically means you are still using the Block Editor, but the ‘Classic Block’.
 * The core issue I linked to above therefore very much applies here. To workaround
   for now you need to save the post content before Published and it should pick
   up the correct category.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Exclude doesn’t work’ is closed to new replies.

 * ![](https://ps.w.org/subscribe2/assets/icon-256x256.png?rev=2318630)
 * [Subscribe2 - Form, Email Subscribers & Newsletters](https://wordpress.org/plugins/subscribe2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/subscribe2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/subscribe2/)
 * [Active Topics](https://wordpress.org/support/plugin/subscribe2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/subscribe2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/subscribe2/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Matt Robinson](https://wordpress.org/support/users/mattyrob/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-doesnt-work-3/#post-12651383)
 * Status: resolved