Wotcha all
Basically I'm trying to add a link to a title and it needs to link to the first post in a certain post category ... but I'm using advanded custom fields so that title is a varialbe so in the code looks like this:
<h2><?php echo get_field('news_title'); ?></h2>
That displays fine, but I need to add the link to is, so what I tried to do is something like this
<?php $postslist = get_posts('category=7&numberposts=1&order=DESC&orderby=post_date');
foreach ($postslist as $post) :
setup_postdata($post); ?>
<h2><a href="<?php the_permalink() ?>">Link title here</a></h2>
<?php endforeach; ?>
Which works fine getting the link, but if I try replacing 'Link title here' with my Advanced custom field variable in that link it doesn't pick it up, so I tried this ... which in my mind should work fine!...
<?php $postslist = get_posts('category=7&numberposts=1&order=DESC&orderby=post_date');
foreach ($postslist as $post) :
setup_postdata($post); ?>
<h2><a href="<?php the_permalink() ?>"><?php echo get_field('news_title'); ?></a></h2>
<?php endforeach; ?>
Should be so simple but I can't get my head around this one! Any idea why it might not be working?
Cheers in advance peeps!