Tagged: custom fields, portfolio item, sorting
-
AuthorPosts
-
December 4, 2018 at 4:42 pm #1040781
I’m using a numeric custom field to sort my portfolio items on a number of pages. More specifically, these are staff profiles that need to be ordered by a custom hierarchy rather than alphabetical by slug. However, I need use these same portfolio items on another page, a directory, where I need to sort by slug alphabetically. Since I’ve edited my functions.php to sort the ‘portfolio’ post-type by the custom field numeric value, is there a way to override and sort the same portfolio items using the settings in the content item?
Here’s my code in functions.php…
// portfolio grid order using listing_order custom field function custom_post_grid_query( $query, $params ) { $query['post_type'] = 'portfolio'; $query['meta_key'] = 'listing_order'; $query['orderby'] = 'meta_value_num'; $query['order'] = 'ASC'; return $query; } add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2);
Can I maybe apply a second custom post type to the same portfolio item? using a different sorting method? Or perhaps assign the sorting method to an id so I can differentiate by what container it’s in?
I appreciate any help.
December 4, 2018 at 11:34 pm #1040994Update – so I’ve installed the Multiple Post Type Order plugin, and can separate two different order systems for the portfolio cpt. Just having a little trouble knowing how to call the appropriate
orderby
,meta_key
, etc in the Portfolio Grid. I do have two separate functions running for each sort – one by my home ACF number, the other by the order from the plugin – but can’t seem to isolate their use in different instances.December 10, 2018 at 1:42 pm #1043068Hi,
Thank you for using Enfold.
Have you tried adding conditional functions to the existing filter? You can try the is_page function in particular.
// https://developer.wordpress.org/reference/functions/is_page/
Best regards,
IsmaelJanuary 7, 2019 at 5:04 am #1050736Thank you, Ismael. This makes perfect sense. I’ll give it a try.
January 7, 2019 at 3:32 pm #1050917January 7, 2019 at 7:46 pm #1051025Got this working. My syntax was wrong in functions.php to find the page id. You can close this out.
January 8, 2019 at 3:50 am #1051156 -
AuthorPosts
- You must be logged in to reply to this topic.