Skip to content

Instantly share code, notes, and snippets.

@PCianes
Last active July 8, 2017 14:32
Show Gist options
  • Save PCianes/8e37c013b2cc621afb2705648e95b037 to your computer and use it in GitHub Desktop.
Save PCianes/8e37c013b2cc621afb2705648e95b037 to your computer and use it in GitHub Desktop.
Add Custom Post States to WordPress posts and pages
<?php
add_filter('display_post_states', 'pc_custom_post_states', 10 , 2);
function pc_custom_post_states($states, $post) {
if( ('page'==get_post_type($post->ID)) && ('page-templates/custom-page-template.php'==get_page_template_slug($post->ID)) ) {
$states[] = __('Custom state');
}
return $states;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment