• Resolved cruzgloriosa

    (@cruzgloriosa)


    Hi,

    I haved this custom function for order my category pages by Name:

    //-------Ordenar Categorías
    function cat_sort_alpha( $query ) {
        if ( is_admin() || ! $query->is_main_query() )
            return; 
    
        if ( is_category() ) {
            $query->query_vars['showposts'] = 300;
    
            remove_action( 'pre_get_posts', __FUNCTION__ );
    // error on this line*****
    add_filter( 'posts_orderby', function() { return ' post_title ASC'; } ); 
    
        }
    } 
    
    add_action( 'pre_get_posts', 'cat_sort_alpha' );

    After today i have this error:

    PHP Parse error: syntax error, unexpected T_FUNCTION in …

    The line indicated is:

    add_filter( 'posts_orderby', function() { return ' post_title ASC'; } );

    My site works if i comment (//) this line, but if i uncomment, the site shows a blank page.

    I need this function for order my category pages.

    It’s a bug? Why this worked and now is not working?

    Thanks.

    https://www.cruzgloriosa.org

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘unexpected T_FUNCTION’ is closed to new replies.