• I’m having an issue with using pre_get_posts I’m currently using a pre_get_posts function to control the loop output of my category template which works fine but I also have a search template and I’m trying to incorporate the arguments used in there into a separate pre_get_posts function.

    This is what I am using, when used it kills the site, white screen, as you might have noticed I’m no expert…

    If anyone is able to point out my most likely glaring mistake I’ll be very grateful.

    function paginate_search ( $query ) {
    if( $query->!is_admin() ) {
    foreach($_POST[‘filter_cat’] as $fcat){$fcat_list .= $fcat . “,”;}
    query_posts( array_merge ( array (
    ‘cat’ => $fcat_list,
    ‘posts_per_page’ => 6,
    ‘paged’ => $paged
    ),
    $wp_query->query
    ) ); } }
    add_action( ‘pre_get_posts’, ‘paginate_search’ );

  • The topic ‘wordpress theme development pre get posts’ is closed to new replies.