-
-
Save tommcfarlin/d934562a8d427d73a86b to your computer and use it in GitHub Desktop.
[WordPress] A long (read: less-than-ideal) way to determine if the current post type exists in the options array of post types.
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
<?php | |
function post_type_is_supported() { | |
$post_types = get_option( 'acme-supported-post-types' ); | |
$current_post_type = get_post_type( get_the_ID() ); | |
$is_supported = false; | |
foreach ( $post_types as $post_type_key => $post_type_val ) { | |
if ( $current_post_type === $post_type_key ) { | |
$is_supported = true; | |
break; | |
} | |
} | |
return $is_supported; | |
} |
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
<?php | |
function post_type_is_supported() { | |
return in_array( get_post_type( get_the_ID() ), array_keys( get_option( 'acme-supported-post-types' ) ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What's in $post_type_val?