This category template enables you to order posts in any category or other taxonomy by the value of the custom field added to each post.
In this case, the value is a price added as a number to a custom field on the Edit Post screen and output with a dollar sign and commas on the front end resulting in posts ordered by price like this :
All elements in this template are customizable including :
- The entire loops WP_Query arguments
- All the hooks for every element on the category archive page
- Layout
- Archive description & title
- Post info & entry meta
- Featured image, image size & alignment
- Excerpt & content limit
- Read more link
- Pagination
Demo Video
Shows posts listed by price in Ascending or Descending order on the category archive page for Genesis child themes.
Tested using the Genesis Sample child theme by StudioPress however works in any Genesis child theme.
Installation Steps
There’s 2 steps :
- # Upload the file named category-new-listings.php to your child theme folder like this :
- # Using ACF ( free or premium version ) create a new number field named price or import the file named acf-72831.json from your WordPress Dashboard > Custom Fields > Tools > Import Field Groups > Import File
Remove Dollar Sign From Existing Values
If you DB contains a large amount of custom field values containing the $ dollar sign, you can perform a custom SQL Database query to remove the $ dollar sign from existing values like this :
Warning : Make sure you take a full database backup before you run this update.
UPDATE wp_postmeta
SET meta_value = REPLACE( meta_value, '$', '' )
WHERE meta_key LIKE 'price';
Was This Tutorial Helpful?