-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>
問候