Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #584585

    Hi there,

    I am trying to get my portfolio items sorted by published date but I can’t get it to work.

    I’ve tried using this code in my child theme functions.php, but it’s not working:

    /* Portfolio sorting order */
    function loop_portfolio_query( $location )
    {
    if ( $location == ‘loop-portfolio’ )
    {
    global $avia_config;
    if(isset($avia_config[‘new_query’]))
    {
    $avia_config[‘new_query’][‘orderby’] = “date”;
    $avia_config[‘new_query’][‘orderby’] = “DESC”;
    query_posts($avia_config[‘new_query’]);
    }
    }
    }
    add_action( ‘avia_action_query_check’ , ‘loop_portfolio_query’, 10, 1 );

    When I replace ‘date’ with ‘rand’ it DOES show a random order each time I reload the page, so it must be something obvious I am overlooking.

    Thanks for helping out!

    #584586
    #584593

    Hi Digit,

    thanks for the quick response. I added the code but I do not see the new ‘orderly’ settings in the Flagship Theme Options > Portfolio. Is this update for Flagship or only for Enfold?

    Thanks!

    #585996

    Hi Yigit,

    any update to my question above?

    Thanks!!

    #586931

    Hi!

    The default sorting of the portfolio items or posts is by date so you don’t have to add the query. Did you install the post type order plugin? Please remove it then try this code:

    function loop_portfolio_query($location)
    {
    	if($location == 'loop-portfolio')
    	{
    		global $avia_config;
    		if(isset($avia_config['new_query']))
    		{
    			$avia_config['new_query']['orderby'] = "date";
    			$avia_config['new_query']['order'] = "ASC";
    			query_posts($avia_config['new_query']);
    		}
    	}
    }
    add_action('avia_action_query_check' , 'loop_portfolio_query', 10, 1);
    

    Best regards,
    Ismael

    #587449

    Hi Ismael,

    that worked, thanks a lot!!

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Portfolio sorting by publish date not working’ is closed to new replies.