• Resolved moonyell

    (@moonyell)


    Hi,
    My question is where I can re-arrange the order of articles. It looks the default order is the earliest-published articles show first always, but I want show the latest article but I have no idea where I can change the setting.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author BasePress

    (@codesavory)

    Hi @moonyell,

    the articles are displayed by date in ascending order.
    You can change that by adding the following hooks to your functions.php:

    //Change post order for a single section page
    add_action( 'pre_get_posts', function( $query ){
    	global $basepress_utils;
    
    	if( $basepress_utils->is_section){
    		$query->set( 'order', 'DESC' );
    	}
    }, 9999 );
    
    //Change post order for multiple sections page
    add_filter( 'basepress_multi_section_query', function( $args ){
    	$args['order'] = 'DESC';
    	return $args;
    } );

    In case you need the Premium version allows you to reorder the results manually with drag & drop.

    Thanks

    Thread Starter moonyell

    (@moonyell)

    Hi,

    The solution works. Thank you very much.

    Yet, when I copy the codes as provided into dreamweaver, it shows red with several lines which usually means there are some error of syntax or else. Since I do not understand PHP, I could not determine what kind erros. But as I said, article order are re-arranged as expected.
    Great job!

    Plugin Author BasePress

    (@codesavory)

    Hi there,

    I am not sure why Dreamweaver would mark any of that code in red but I can reassure you that there are no errors.

    Thanks

    Thread Starter moonyell

    (@moonyell)

    Hello,

    Thanks for your quick response. My question being solved.
    Good job!!!

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