I'm trying to compare the permalink with a url and then output stuff depending if they match. At the moment I have the code below. On the page it's visibly showing that the permalink and the url (i.e $company) match yet it's outputting "don't show news articles".
Where am I going wrong?
<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. ?>