请试试这个,告诉我结果
function my_shortcode_to_a_post( $content ) {
global $post;
$disabled_post_ids = array(\'20\', \'31\', \'35\');
$disabled_tag_ids = array(\'5\', \'19\', \'25\');
$current_post_id = get_the_ID(); // try setting it to $post->ID; if it doesn\'t work for some reason
if(in_array($current_post_id, $disabled_post_ids)) {
return $content;
}
$current_post_tags = get_the_tags($current_post_id);
if($current_post_tags){
$tags_arr = array();
foreach ($current_post_tags as $single_tag) {
$tag_id = $single_tag->term_id;
if(in_array($tag_id, $disabled_tag_ids)) {
return $content;
}
}
}
switch( $post->post_type ) {
case \'post\':
return $content . \'[table id=1 /]\';
case \'page\':
return $content . \'[table id=1 /]\';
default:
return $content;
}
}
add_filter( \'the_content\', \'my_shortcode_to_a_post\' );