目次
functions.php
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;
}
wpmem_block
コメント