Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter stpetersphila

    (@stpetersphila)

    I never did, as I recall. The solution, unfortunately, was to modify the plugin’s settings in the database directly. I do not remember more specifically than that, I’m afraid. I remember calling several searches for “ai1ec” throughout the various tables and eventually finding the cache directory. I also recall it being difficult to find and not where I expected it.

    Thread Starter stpetersphila

    (@stpetersphila)

    I’ve figured out code works. I’ve put this in my functions.php file, and it behaves as expected, not including posts categorized ONLY as excluded categories, but including posts categorized with an excluded and NONexcluded category.

    I’ll mark as resolved in a day or two if nobody chimes in with a more elegant solution.

    function exclude_categories( $query ) {
     if ( $query->is_home() && $query->is_main_query() ) {
      $cats = array();
      $category_ids = get_all_category_ids();
      foreach( $category_ids as $cat_id ) {
       if ( ( $cat_id != 1) && ( $cat_id != 5) && ( $cat_id != 40) ){
        $cats[] = $cat_id;
       }
      }
      $query->set( 'category__in', $cats );
     }
    }
    add_action( 'pre_get_posts', 'exclude_categories' );

    I struggled for a while before I realized I couldn’t pass an array to ‘cat’.

    Thread Starter stpetersphila

    (@stpetersphila)

    Thank you for your response, Evan. However that code functions the same as my first function: excluding all posts with that category regardless of other categories the post may have.

    I am looking, rather than to exclude a category, to fail to include a particular category.

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