Last Updated: February 25, 2016
·
1.12K
· leoj3n

Definitively Verify (Custom) Post Type

Use this function...

<?php
function my_verify_post_type() {
  global $post_type;

  $type = 'movie'; // a custom P.T.

  if (isset( $_GET['post_type'] )
   && $_GET['post_type'] == $type
   || isset( $post_type ) && $post_type == $type) 
   return true; // return true if on a page of type $type

  return false;
}
?>

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

WordPress sites collect scripts from themes, plugins, and tag managers. A compromised plugin update can add a skimmer to every page without a change in your own templates.

Security insights from Cside