此时,我正在使用下面的代码,为所有帖子和页面上的表添加一个短代码,但我想排除少数页面和任何带有特定标记的帖子。(例如页面id 10、20和标签id 30)
我对这一切都很陌生,我还在学习。
function my_shortcode_to_a_post( $content ) {
global $post;
if( ! $post instanceof WP_Post ) 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\' );
提前谢谢你的帮助。