Support

Account

Home Forums ACF PRO Retrieving option throws massive error Reply To: Retrieving option throws massive error

  • Yes it is (located in a pre_get_posts filter), as shown below.

    function profile_search_form( $query ) {
        $results_per_page = get_option( 'posts_per_page' );
        $paged            = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
        $exclude          = sd_exclude_dummy();
    
        if ( ! is_admin() && $query->is_main_query() && isset( $_GET['ssd8'] ) && 1 == $_GET['ssd8'] ) {
    
            // output on search page
            if ( $query->is_search ) {
    
                $no_errors = false;
                include( get_template_directory() . '/inc/search/profile-search-query.php' );
    
                if ( true == $no_errors ) {
    
                    $query->set( 's', false );
                    $query->set( 'post_type', PostTypes::PROFILE );
                    $query->set( 'post__not_in', $exclude );
                    $query->set( 'posts_per_page', $results_per_page );
                    if ( isset( $_GET[ 'sp' ] ) && 'tour' == $_GET[ 'sp' ] ) {
                        add_filter( 'posts_where', 'sd_tour_cities_searches' );
                    }
                    $query->set( 'meta_query', $meta_query );
                    $query->set( 'tax_query', $tax_query );
                }
            }
        }
    }
    add_action( 'pre_get_posts', 'profile_search_form' );

    It exists in a few queries, since I need to hide this dummy post for regular visitors. It only needs to show in archives sometimes, when I test things.

    How can I easily solve this ?

    Would defining it as a constant be a simple solution ?