-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5d34c7
commit e132a8e
Showing
16 changed files
with
263 additions
and
274 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
root: ./docs/ | ||
structure: | ||
readme: ../README.md |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,16 @@ | ||
# Table of Contents | ||
|
||
* [Getting Started](01-getting-started.md) | ||
* [Requirements](01-getting-started.md#requirements) | ||
* [Installation](01-getting-started.md#installation) | ||
* [Basic Usage](01-getting-started.md#basic-usage) | ||
* [PostTypes](02-posttypes.md) | ||
* [Create a new PostType](02-posttypes.md#create-a-new-posttype) | ||
* [Working with exisiting PostTypes](02-posttypes.md#working-with-exisiting-posttypes) | ||
* [Add Taxonomies](02-posttypes.md#add-taxonomies) | ||
* [Filters](02-posttypes.md#filters) | ||
* [Columns](02-posttypes.md#columns) | ||
* [Menu Icons](02-posttypes.md#menu-icons) | ||
* [Flush Rewrite Rules](02-posttypes.md#flush-rewrite-rules) | ||
* [Taxonomies](03-taxonomies.md) | ||
* [Create a new Taxonomy](03-taxonomies.md#create-a-new-taxonomy) | ||
* [Working with exisiting Taxonomies](03-taxonomies.md#working-with-exisiting-taxonomies) | ||
* [Add to PostType](03-taxonomies.md#add-to-posttype) | ||
* [Columns](03-taxonomies.md#columns) | ||
* [Notes](04-notes.md) | ||
* [Translations](04-notes.md#translations) | ||
* [Custom Fields](04-notes.md#custom-fields) | ||
* [Examples](04-notes.md#examples) | ||
* [Getting Started](Getting-started.md) | ||
* [PostTypes](posttypes/README.md) | ||
* [Create a new PostType](posttypes/Create-a-new-posttype.md) | ||
* [Add Taxonomies](posttypes/Add-taxonomies.md) | ||
* [Filters](posttypes/Filters.md) | ||
* [Columns](posttypes/Columns.md) | ||
* [Menu Icons](posttypes/Menu-icons.md) | ||
* [Flush Rewrite Rules](posttypes/Flush-rewrite-rules.md) | ||
* [Taxonomies](taxonomies/README.md) | ||
* [Create a new Taxonomy](taxonomies/Create-a-new-taxonomy.md) | ||
* [Add to PostType](taxonomies/Add-to-post-type.md) | ||
* [Columns](taxonomies/Columns.md) | ||
* [Notes](Notes.md) | ||
* [Changelog](../Changelog.md) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Add Taxonomies | ||
|
||
New and existing Taxonomies can be added to a PostType using its `taxonomy()` method by passing the taxonomy name. | ||
|
||
```php | ||
// Create a books post type | ||
$books = new PostType('book'); | ||
|
||
// Add the genre taxonomy to the book post type | ||
$books->taxonomy('genre'); | ||
|
||
// Register the post type to WordPress | ||
$books->register(); | ||
``` | ||
See the [documentation](#) on creating a new Taxonomy. Taxonomies and PostTypes can be created in any order. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Columns | ||
|
||
You can now modify a PostTypes admin columns using the `column()` manager. | ||
|
||
#### Adding Columns | ||
|
||
You can add columns to the admin edit screen by passing an array of slugs and labels to the `add()` method. | ||
|
||
```php | ||
// add multiple columns and set their labels | ||
$books->columns()->add([ | ||
'rating' => __('Rating'), | ||
'price' => __('Price') | ||
]); | ||
``` | ||
|
||
#### Hiding Columns | ||
|
||
You can hide columns by passing the column slug to the `hide()` method. You can hide multiple columns by passing an array of column slugs. | ||
|
||
```php | ||
$books->columns()->hide('author'); | ||
|
||
$books->columns()->hide(['author', 'date']); | ||
``` | ||
|
||
#### Set Columns | ||
|
||
You can force set all the columns to display on the admin page with the `set()` method by passing an array of the column slugs and labels. | ||
|
||
```php | ||
$books->columns()->set([ | ||
'cb' => '<input type="checkbox" />', | ||
'title' => __("Title"), | ||
'genre' => __("Genres"), | ||
'rating' => __("Rating"), | ||
'date' => __("Date") | ||
]); | ||
``` | ||
|
||
#### Column Order | ||
|
||
After hiding and adding columns you may want to rearrange the column order. To do this use the `order()` method. You only have to pass through an array of the columns you want to reposition, not all of them. Their positions are based on a zero based index. | ||
|
||
```php | ||
$books->columns()->order([ | ||
'rating' => 2, | ||
'genre' => 4 | ||
]); | ||
``` | ||
|
||
#### Populating Columns | ||
|
||
You can populate any column using the `populate()` method and passing the column slug and function. | ||
|
||
```php | ||
$books->columns()->populate('rating', function($column, $post_id) { | ||
echo get_post_meta($post_id, 'rating', true) . '/10'; | ||
}); | ||
``` | ||
|
||
#### Sorting Columns | ||
|
||
You can choose which custom columns are sortable with the `sortable()` method. This method accepts an array of column slugs and an array of sorting options. | ||
|
||
The first option is the `meta_key` to sort the colums by. | ||
|
||
The second option is whether to order the items numerically (`true`) or alphabetically (`false`) by default. | ||
|
||
```php | ||
// will make both the price and rating columns sortable and ordered numerically | ||
$books->columns()->sortable([ | ||
'price' => ['price', true], | ||
'rating' => ['rating', true] | ||
]); | ||
``` |
Oops, something went wrong.