Last active
September 29, 2017 14:53
-
-
Save jessepearson/0a1965c7bb1eea5e67269a947e15f9ce to your computer and use it in GitHub Desktop.
Reordering membership content on My Membership Content page in WooCommerce Memberships
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php // only copy this line if needed | |
| /** | |
| * This function allows for the editing of the query args for the query that displays the posts/content on the My Membership Content page | |
| * | |
| * Works with Memberships v1.6.3 | |
| * | |
| * @param array $query_args The query arguements | |
| * @param string $type The type of restriction being queried, unused in this case. | |
| * @param int $paged The page, if paged, also unused. | |
| * @see https://codex.wordpress.org/Class_Reference/WP_Query | |
| * @return array The $query_args array | |
| */ | |
| function reorder_wc_memberships_posts_listing( $query_args, $type, $paged ) { | |
| // Set the posts to be ordered by the Title, and ascending (A-Z) | |
| $query_args['orderby'] = 'title'; | |
| $query_args['order'] = 'asc'; | |
| return $query_args; | |
| } | |
| add_filter( 'wc_memberships_get_restricted_posts_query_args', 'reorder_wc_memberships_posts_listing', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment