Created
December 31, 2016 05:06
-
-
Save arelthia/4d130b8871ed8a13cb4e68df0c6d82a7 to your computer and use it in GitHub Desktop.
Get WordPress CPT from front end
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