-1
我想只显示在url中包含某个单词的帖子。我得到了这个,但它不起作用。我想要在网址中包含博客或新闻的所有帖子。检查URL是否包含某个词php wordpress
<?php
$url = $_SERVER["REQUEST_URI"];
$isItBlog = strpos($url, 'scotch');
$isItNews = strpos($url, 'soda');
if ($isItBlog!==false)
{
?>
<h1 class="cat">Worked with - </h1>
<h1 class="entry-title"><a title="<?php printf(esc_attr__('Permalink to %s', 'compass'), the_title_attribute('echo=0')); ?>" href="<?php the_permalink(); ?>" rel="bookmark"> <?php the_title(); ?>
</a></h1>
<div class="clearfix"></div>
<?php the_post_thumbnail('category-thumb'); ?>
<div class="entry-content"><?php the_content(); ?></div>
<?php
}
if ($isItNews!==false)
{
?>
<h1 class="entry-title"><a title="<?php printf(esc_attr__('Permalink to %s', 'compass'), the_title_attribute('echo=0')); ?>" href="<?php the_permalink(); ?>" rel="bookmark"> <?php the_title(); ?>
</a></h1>
<div class="clearfix"></div>
<?php the_post_thumbnail('category-thumb'); ?>
<div class="entry-content"><?php the_content(); ?></div>
<?php } ?>
</article>
问候