• This is a pretty simple question honestly confused I haven’t figured this out by now because it is so simple. How do I do if or. The code kinda shows what I want to do. I have feel like I have tried everything. if ($post_type != 'acf-field-group || ct_template') if (($post_type != 'acf-field-group') || ($post_type != 'ct_template')) But everything fails.

    
    add_action( 'init','remove_support');
    function remove_support() {
    			$post_types = get_post_types();
    		foreach ($post_types  as $post_type ) 
    			{
    			if ($post_type != 'acf-field-group')
    				{
    				if ($post_type != 'ct_template')
    					{
    						if ($post_type != 'search-filter-widget')
    							{
    								remove_post_type_support($post_type, 'editor');
    								remove_post_type_support($post_type, 'title');
    								remove_post_type_support($post_type, 'author');
    								remove_post_type_support($post_type, 'thumbnail');
    								remove_post_type_support($post_type, 'trackbacks');
    								remove_post_type_support($post_type, 'comments');
    								remove_post_type_support($post_type, 'revisions');
    								remove_post_type_support($post_type, 'post-formats');	
    							}
    					}
    				}
    			}
    	}
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Your first example is not at all close. The second one is closer, but I think ACF uses post meta, not post types.

    Moderator bcworkz

    (@bcworkz)

    Maybe it’s just me not being able to think straight, but I’ve never found the use of NOT operators like != in conjunction with logical AND and OR to be very intuitive. I’ve found I tend to use OR when I need AND, or vice versa. If your code doesn’t execute when you think it should, it may be you needed && instead of ||.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘If or’ is closed to new replies.