Skip to content

Instantly share code, notes, and snippets.

@nguyenvanduocit
Last active June 19, 2016 15:27
Show Gist options
  • Save nguyenvanduocit/9e4ab194fe0791548e7d9fa7452e13fa to your computer and use it in GitHub Desktop.
Save nguyenvanduocit/9e4ab194fe0791548e7d9fa7452e13fa to your computer and use it in GitHub Desktop.
Post Status Template
{
"fields": {
"slug": {
"type": "text",
"label": "Name",
"value": "unread",
"placeholder": "",
"description": "Name of the post status. Maximum length is 20 characters.",
"required": true
},
"singular_name": {
"type": "text",
"label": "Singular label",
"value": "Unread",
"placeholder": "",
"description": "",
"required": true
},
"plural_name": {
"type": "text",
"label": "Plural label",
"value": "Unreads",
"placeholder": "",
"description": "",
"required": true
},
"public": {
"type": "checkbox",
"label": "Is public",
"value": true,
"placeholder": "",
"description": "Whether posts of this status should be shown in the front end of the site.",
"required": true
},
"show_in_admin_all_list": {
"type": "checkbox",
"label": "Show in admin all list",
"value": true,
"placeholder": "",
"description": "Whether to include posts in the edit listing for their post type.",
"required": true
},
"show_in_admin_status_list": {
"type": "checkbox",
"label": "Show in admin status list",
"value": true,
"placeholder": "",
"description": "Show in the list of statuses with post counts at the top of the edit listings, e.g. All (12) , Published (9) , My Custom Status (2) ...",
"required": true
},
"exclude_from_search": {
"type": "checkbox",
"label": "Exclude from search",
"value": true,
"placeholder": "",
"description": " Whether to exclude posts with this post status from search results.",
"required": true
}
}
}
{
"name": "Post Status",
"templates": [
{
"file": "register.php",
"title": "Register new post type"
},
{
"file": "usage.php",
"title": "Usage"
}
]
}
<?php
function {{function_prefix}}_register_{{slug}}_post_status(){
register_post_status( '{{slug}}', array(
'label' => _x( '{{singular_name}}', 'post' ),
'public' => {{public}},
'exclude_from_search' => {{exclude_from_search}},
'show_in_admin_all_list' => {{show_in_admin_all_list}},
'show_in_admin_status_list' => {{show_in_admin_status_list}},
'label_count' => _n_noop( '{{singular_name}} <span class="count">(%s)</span>', '{{plural_name}} <span class="count">(%s)</span>' ),
) );
}
add_action( 'init', '{{function_prefix}}_register_{{slug}}_post_status()' );
<?php $args = array(
'post_status' => '{{slug}}'
);
$posts_array = get_posts( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment