Created
August 1, 2019 23:42
-
-
Save wplit/f380710a33e08889f11f8ceccec9b75b to your computer and use it in GitHub Desktop.
Is single post (of post type) condition
This file contains hidden or 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
| add_action('init', 'lit_register_condition_single_post_type'); | |
| function lit_register_condition_single_post_type() { | |
| global $oxy_condition_operators; | |
| $postTypes = get_post_types(); | |
| oxygen_vsb_register_condition('Single Post Type', array('options'=> array_keys($postTypes)), $oxy_condition_operators['simple'], 'lit_condition_single_post_type_callback', 'Post'); | |
| } | |
| function lit_condition_single_post_type_callback($value, $operator) { | |
| if($operator == '==') { | |
| return ( is_singular($value) ) ? true : false; | |
| } | |
| else { | |
| return ( !is_singular($value) ) ? true : false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi and thanks for that snippet.
However, I would put it inside :