我试图将永久链接与url进行比较,然后根据它们是否匹配输出内容。目前我有下面的代码。在页面上,它明显地显示permalink和url(即$company)匹配,但它输出“不显示新闻文章”。
我哪里做错了?
<p>permalink of current page: <?php $link = get_permalink(); echo $link; ?></p>
<?php $portfolioloop = new WP_Query( array( \'post_type\' => \'news\' ) ); ?>
<?php while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post(); ?>
<?php while(the_repeater_field(\'featured_companies\')): ?>
<p>url of linked page: <?php $company = the_sub_field(\'featured_company\'); ?></p>
<?php if ($link == $company) { ?>
show news articles
<?php } else { ?>
don\'t show news articles
<?php } ?>
<?php endwhile; ?>
<?php endwhile; // end of the loop. ?>