functions.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
function my_custom_post_types() { $settings = array( 'カスタム投稿A' => 'block', 'カスタム投稿B' => 'unblock', ); return $settings; } add_filter( 'wpmem_block', 'block_custom_post_types' ); function block_custom_post_types( $block ) { global $post; $post_type = get_post_type( $post ); $my_cpts = my_custom_post_types(); if ( is_single() && ( array_key_exists( $post_type, $my_cpts ) ) ) { $cpt_block = ( $my_cpts[ $post_type ] == 'block' ) ? true : false; $meta = get_post_meta( get_the_ID(), '_wpmem_block', true ); if( $cpt_block ) { if ( isset( $meta ) && $meta == 0 ) { $block = false; } } else { if ( isset( $meta ) && $meta == 1 ) { $block = true; } } } return $block; } |
参考ページ
http://rocketgeek.com/plugins/wp-members/docs/filter-hooks/wpmem_block/
コメント