WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Query mod broken in WP 3.1

[Resolved] Query mod broken in WP 3.1

  • My functions.php file contains a query modifier for the homepage to exclude categories that I don’t want appearing there. With the 3.1 upgrade this is somehow broken now. Can anyone tell me why? Here’s what my code looks like in functions.php

    <?php
    function myFilter($query) {
    	if ($query->is_home) {
    		$query->set('cat','-1,-11,-12,-4,-23,-24');
    	}
    return $query;
    }
    add_filter('pre_get_posts','myFilter');
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Some category excluder plugins such as Ultimate Category Excluder may be broken as well. That one is actually a bug: Trac Ticket
    The Hotfix plugin now has a fix that might help: http://wordpress.org/extend/plugins/hotfix/

    Thanks lpstenu. In the Trac Ticket link I found a solution, posted below for anyone with similar issues.

    <?php
    function exclude_category($query) {
    	if ( $query->is_home ) {
    		$query->set('category__not_in', array(1,11,12,4,23,24));
    	}
    	return $query;
    }
    add_filter('pre_get_posts', 'exclude_category');
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Query mod broken in WP 3.1’ is closed to new replies.
Skip to toolbar