-
-
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.
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
(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