Elegant Themes sort portfolio page

from: https://www.elegantthemes.com/forum/viewtopic.php?f=143&t=65058&hilit=sort+posts+portfolio

Go to the page-template-portfolio.php and replace this code:

<?php query_posts(“showposts=$et_ptemplate_gallery_perpage&paged=$paged” . $gallery_query); ?>

with

<?php query_posts(“showposts=$et_ptemplate_gallery_perpage&meta_key=keyname&orderby=meta_value&paged=$paged” . $gallery_query); ?>

Where keyname is a name of custom field.
Note that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).

Leave a comment