Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/6ff1ed70015f6f5aac92 to your computer and use it in GitHub Desktop.
Save tommcfarlin/6ff1ed70015f6f5aac92 to your computer and use it in GitHub Desktop.
[WordPress] A way to get the post type of the current post in the dashboard on the client-side.
(function( $ ) {
'use strict';
var attrs, attr, postType;
postType = null;
$(function() {
// Look to see what type of post type we're working with
attrs = $( 'body' ).attr( 'class' ).split( ' ' );
$( attrs ).each(function() {
if ( 'post-type-' === this.substr( 0, 10 ) ) {
postType = this.split( 'post-type-' );
postType = postType[ postType.length - 1 ];
return;
}
});
});
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment