Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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