 
	
		Tagged: devin-docs, Masonry Entries, orderby, sorting
- 
		AuthorPosts
- 
		
			
				
February 22, 2014 at 10:27 pm #227963Hi there, 
 I’m using the Masonry Entries to display posts on several pages on my site. In most cases I want these sorted by most recent first, which I achieved by editing masonry_entries.php. For one page, however, I would like the entries sorted alphabetically. Is it possible to do this by addind some code to the masonry_entries.php? Or even in the shortcode on that page?Thanks! February 24, 2014 at 5:13 pm #228561Hey topergarden! No not that I know of. I’ll tag the topic for the head of support who may know of a filter that will work on an individual page. Cheers! 
 DevinFebruary 25, 2014 at 8:07 am #228895Hi! You can use this code – insert it into the functions.php file: add_filter('avia_masonry_entries_query', 'avia_random_image_query', 10, 2); function avia_random_image_query($query, $params) { if(is_page(array(20))) { $query['orderby'] = "ASC"; $query['order'] = "title"; } return $query; }Replace 20 with the id of the page where you want to sort the entries alphabetically. Regards, 
 PeterFebruary 25, 2014 at 8:56 am #228908Thanks! I made the mistake of pasting that in my functions.php of enfold, rather than in my child theme functions.php. This broke the site (just returns a blank page, even for the dashboard). I got back in through ftp and edited functions.php back to how it was, still broken. I even downloaded the theme again and replaced functions.php and it’s still broken. Help!!! February 25, 2014 at 9:22 am #228915UPDATE: I’ve managed to fix it – learnt about debugging and found the syntax error. I’ve now added the code to my child theme functions.php but I get the error… Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home4/chrisga3/public_html/bodyboard/wp-content/themes/enfold-child/functions.php on line 29 Line 29 is this bit… function avia_random_image_query($query, $params) Any ideas? February 25, 2014 at 5:09 pm #229066I just tried it out with my live child them and didn’t any errors. The query values were reversed so it should be the following: add_filter('avia_masonry_entries_query', 'avia_random_image_query', 10, 2); function avia_random_image_query($query, $params) { if(is_page(array(5173))) { $query['orderby'] = "title"; $query['order'] = "ASC"; } return $query; }but it shouldn’t cause any errors. Just make sure your functions file has an opening ‘<?php’ and the function is after that. February 25, 2014 at 9:00 pm #229190Thanks very much! Hmmm, still can’t work out what is going on though. Here’s my current child functions.php… <?php /* * Add your own functions here. You can also copy some of the theme functions into this file. * WordPress will use those functions instead of the original functions then. */ //Add title attribute back to gallery images function my_image_titles($atts,$img) { $atts['title'] = trim(strip_tags( $img->post_title )); return $atts; } add_filter('wp_get_attachment_image_attributes','my_image_titles',10,2); add_filter('avf_title_args', 'fix_single_post_title', 10, 2); function fix_single_post_title($args,$id) { if (is_single()) { $args['title'] = get_the_title($id); $args['link'] = get_permalink($id); } return $args; }I simply pasted your code at the bottom of this and it still breaks it. Strange! February 26, 2014 at 4:00 am #229391Hi, I tried with your exact functions.php file + the avia_random_image_query function and got no errors so far, can you create an administrator account and post it here as a private reply? Regards, 
 JosueFebruary 26, 2014 at 8:42 am #229455This reply has been marked as private.February 26, 2014 at 7:42 pm #229729Added the code: 
 http://www.bodyboard.co.nz/wp-admin/theme-editor.php?file=functions.php&theme=enfold-child&scrollto=162&updated=trueNo errors so far, please check if the changes have been applied to your Masonry elements. Cheers! 
 JosueFebruary 26, 2014 at 8:43 pm #229759Cheers! it’s working perfectly and has ordered the page alphabetically. Thanks very much for the outstanding support! 
- 
		AuthorPosts
- The topic ‘Order of Masonry Entries’ is closed to new replies.
