Forum Replies Created

Viewing 1 replies (of 1 total)
  • I drove myself nuts trying to exclude individual pages from the search.php, while still keeping the original query and finally came up with this solution:

    placed in functions.php

    function filter_where($where = '') {
    	if ( is_search() ) {
    		$exclude = array(2480,2209,2454,2204,2488,2482,2463,2465,2458,2467,2461,2486,2211,2484,2200,2196,2198,2229,2219,2469,2490,2492,2218,2471,2473,2478,2496,2494,2476,2456);	
    
    		for($x=0;$x<count($exclude);$x++){
    		  $where .= " AND ID != ".$exclude[$x];
    		}
    	}
    	return $where;
    }
    add_filter('posts_where', 'filter_where');

    Where exclude array are the post ID’s.

    This will append to the original query_string and will still show the correct number of results, instead of being inside of the loop and excluding these pages, because when this happens, if I exclude say 8 of the 10 that will display I only see two results, and I need a constant 10. Hope this helps someone

Viewing 1 replies (of 1 total)