Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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.

    #1040994

    Update – 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.

    #1043068

    Hi,

    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,
    Ismael

    #1050736

    Thank you, Ismael. This makes perfect sense. I’ll give it a try.

    #1050917

    Hi,

    Alright. Let us know if you need anything else.

    Best regards,
    Ismael

    #1051025

    Got this working. My syntax was wrong in functions.php to find the page id. You can close this out.

    #1051156

    Hi,

    Great! Glad that you figured it out. Please open a new thread if you need anything else.

    Have a nice day.

    Best regards,
    Ismael

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.