I am trying to get the permalink and title into variables to use outside of a loop - I have made it work for the thumbnail but for some reason can t get it to work for these two.
Here is my code:
<div class="medium-12 medium-centered columns">
<?php global $post; // required
$args = array('category' => 5,
'posts_per_page'=> 7); // include category 5 (Action)
$custom_posts = get_posts($args);
$count3=1;
foreach($custom_posts as $post) : setup_postdata($post);
$v = get_the_post_thumbnail($post->ID, 'medium');
$var = "img".$count3;
$$var = $v;
$l = get_the_permalink();
$link = "link".$count3;
$$l = $l;
$t = get_the_title();
$tt = "title".$count3;
$$t = $t;
?>
<?php $count3++; ?>
<?php endforeach; ?>
<div class="row collapse imageGrid photogrid" data-equalizer="fullRow">
<div class="medium-4 columns" data-equalizer-watch="fullRow">
<a href="<?php echo $link1; ?>">
<span class="centertitle"><?php echo $title1; ?></span>
<?php echo $img1; ?>
</a>
</div>
<div class="medium-4 columns" data-equalizer-watch="fullRow" data-equalizer="watchColumn">
<div class="row collapse" data-equalizer-watch="watchColumn">
<?php echo $img2; ?>
</div>
<div class="row collapse" >
<div class="medium-6 columns" data-equalizer-watch="watchColumn"> <?php echo $img3; ?></div>
<div class="medium-6 columns" data-equalizer-watch="watchColumn"><?php echo $img4; ?></div>
</div>
</div>
<div class="medium-4 columns" data-equalizer-watch="fullRow" data-equalizer="watchColumn2">
<div class="row collapse">
<div class="medium-6 columns" ><?php echo $img5; ?></div>
<div class="medium-6 columns" ><?php echo $img6; ?></div>
</div>
<div class="row collapse" data-equalizer-watch="watchColumn2">
<?php echo $img7; ?>
</div>
</div>
<?php wp_reset_query(); ?>
</div>
</div>
I have tried different ways of putting the title including:
$t = the_title('', '', false);
as $t = the_title() echos the title straight away.
Any help in how to put them into the variable would be much appreciated