Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #301160

    Hi is there any way to sort the masonry galleries by image title?
    Thanks.

    #301164
    #301290

    Hi, thanks for the link but the instructions don’t seem to be working.
    I’ve added it to the child themes function.php saved it, gone to the page with the masonry gallery, and there’s no extra sort option when editing it. I’ve tried refreshing the page and restarting the browser but still no luck. :(

    #301452

    Hi!

    I’m sorry but the sort order is for the Masonry element only. You need to manually sort the masonry gallery images.

    Regards,
    Ismael

    #301564

    Surely there must be some code I could edit to arrange them? I guess I would have to change ASC to TITLE somewhere?
    Would take me ages to alphabetically arrange over a hundred images manually.

    #301759

    Hey!

    Try to insert this code into the theme functions.php file:

    
    if(!function_exists('avia_change_posts_query'))
    {
    	function avia_change_posts_query($query, $params)
    	{
    	    if(!empty($query['orderby']) && $query['orderby'] == 'post__in')
    	    {
                       $query['order'] = 'ASC';
                       $query['orderby'] = 'title';
    	    }
    	
    	    return $query;
    	}
    	
    	add_filter('avia_masonry_entries_query', 'avia_change_posts_query', 10, 2);
    }
    
    

    Cheers!
    Peter

    #302580

    Hi Peter,
    Added the code to the child theme but got this error: Parse error: syntax error, unexpected ‘{‘, expecting T_STRING or T_VARIABLE or ‘$’ in /home/ufitkitc/public_html/wp-content/themes/enfold-child/functions.php on line 3
    Don’t know much about php coding so can’t spot the error myself.
    Cheers.

    #303260

    Hi!

    Please try copy&pasting the code Peter posted from here directly – http://pastebin.com/jbUd7dKQ
    It does work fine on my local installation

    Regards,
    Yigit

    #303371

    Thanks,
    Tried the code from pastebin and it worked perfectly, also tried peters code again and that worked so I must of copied it wrong :(
    Cheers.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Sort masonry gallery by title’ is closed to new replies.