https://github.com/vutran/wp-grid-sorter
WordPress plugin to sort your posts by custom sort keys
https://github.com/vutran/wp-grid-sorter
grid php plugin wordpress wp
Last synced: about 2 months ago
JSON representation
WordPress plugin to sort your posts by custom sort keys
- Host: GitHub
- URL: https://github.com/vutran/wp-grid-sorter
- Owner: vutran
- Created: 2014-04-06T02:54:23.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-01T05:11:28.000Z (about 12 years ago)
- Last Synced: 2025-02-24T14:27:25.130Z (over 1 year ago)
- Topics: grid, php, plugin, wordpress, wp
- Language: PHP
- Size: 285 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WordPress Grid Sorter
Sort your WordPress posts with custom sort keys
# Functions
`wp_grid_sorter_register_sort_key($sortKey, $args)`
## Arguments
`name` Specify the name to display in the CMS
`post_type` Specify the post type for this key
# Register a custom sort key by post type
'Sort All Posts',
'post_type' => 'post'
);
wp_grid_sorter_register_sort_key('sort_all_posts', $args);
}
}
?>
# Register a custom sort key by custom WP_Query
'Home Page Featured',
'query' => new WP_Query(array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'featured',
'value' => 1
)
)
))
);
wp_grid_sorter_register_sort_key('home_page_featured', $args);
?>
# Query posts and order by your custom sort key
This is automatically hooked into [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query). Please refer to the documentation for [order by a meta key](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) in the WordPress Codex.
## Example:
'post',
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'home_page_featured'
);
$myCustomQuery = new WP_Query($args);
?>