Hi John
I’ve now got this to work –
<?php
$hb1 = in_category(
array('News','Features','Tech'),
$this->post->ID
);
$hb2 = in_category( array('Research'), $this->post->ID );
$hb3 = has_tag(
array( 'aged care', 'anxiety/stress', 'autism', 'cognitive', 'Dementia', "Parkinson's", 'sleep' , 'well-being' ), $this->post->ID
);
if ( $hb1 )
{
$link = get_field('media_outlet_url', $this->post->ID);
$media = get_field ('media_outlet', $this->post->ID);
$country = get_field ('country', $this->post->ID);
$publicationdate = get_field ('publication_date', $this->post->ID);
echo "<a href=$link target="_blank">$media</a>";
echo $publicationdate;
echo $country;
}
else if ( $hb2 && $hb3 )
{
the_field('media_outlet', $this->post->ID);
the_field('published_date', $this->post->ID);
the_field('country', $this->post->ID);
}
?>
Just trying to work out how to get the link to open in a blank page.
Best
G
Hi John
Thanks for getting back to me. I have tried to implement your suggestion but seem to be missing something – I am newish to php so my skills are improving daily but clearly not good enough to identify the problem.
I implemented this off the back of your suggestion –
<?php
$hb1 = in_category(
array('News','Features','Tech'),
$this->post->ID
);
$hb2 = in_category( array('Research'), $this->post->ID );
$hb3 = has_tag(
array( 'aged care', 'anxiety/stress', 'autism', 'cognitive', 'Dementia', "Parkinson's", 'sleep' , 'well-being' ),
$this->post->ID
);
$link = get_field('media_outlet_url', $this->post->ID);
if ( $hb1 )
{
?>
<a href="<php echo $link; ?>" target="_blank"><?php the_field('media_outlet',$this->post->ID); ?</a>
<?php
the_field('published_date', $this->post->ID);
the_field('country', $this->post->ID);
}
else if ( $hb2 && $hb3 )
{
the_field('media_outlet', $this->post->ID);
the_field('published_date', $this->post->ID);
the_field('country', $this->post->ID);
}
?>
But get an error.
Any help appreciated.
Thanks.
Best
G
Apologies I have just noticed my copy and paste didn’t work properly. post->ID );?> target=”_blank”><?php echo get_the_title( $this->post->ID );?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.