我当前正在使用此循环:
if (is_single() || is_page() ) :
if (have_posts() ) :
while (have_posts() ) :
the_post();
如何在循环中排除多个页面例如,我想排除页面
example.com/music
和example.com/contact
.编辑:
我已经按照通用汽车提供的方式做了,但我的音乐和联系人页面在申请后一直在加载。
<?php if (is_single() || is_page() ) : if (have_posts() ) : $exclude_pages = array(\'music\', \'contact\'); while (have_posts() ) : if ( is_page() && ! empty($exclude_pages) && (
in_array($post->post_name, (array)$exclude_pages) ||
in_array($post->post_name, (array)$exclude_pages)
) ) continue; the_post(); ?>
<meta name="description" content="<?php the_content_limit(150)?>" />
// loop continues
<?php endwhile; endif;
elseif (is_home() ): ?>
// loop continues
<?php endif; ?>
<?php if( is_page( \'music\' )) { ?>
<meta property="og:image" content="" />
//loop continues
<?php } ?>
所以要澄清一下:我想排除一些通过标题中的循环生成的元标记。phpNow使用我的循环,所有页面和帖子都会受到循环的影响。因此,我不希望页面music和contact具有来自循环页眉的相同页眉标记。php。