Can anyone please help me wrap the condition inside another condition in php.
I have this code #1 that I want to be inside code #2.
Here’s code #1
<?php if( get_field('highlights') ): ?>
<div class="overview">
<h3>Quick Overview</h3>
<?php the_field('highlights'); ?>
</div>
<?php endif; ?>
Here’s code #2
<?php if(strstr($_SERVER['HTTP_REFERER'],'www.example.com'))
{
echo '**CODE #1 should be placed here**';
}
?>
Sorry, I don’t haev any knowledge in PHP.
Wrapping code 1 inside code 2
2
Answers
After several trial and error, here's what I have to make it work. Please correct me if there's something wrong or to improve.
This should work in theory. Though I’m unsure what the
highlights
field is for.You may want to replace
<?php the_field('highlights'); ?>
with something like<?=highlight ?>
and iterate through the highlights in a loop. That depends on the situation though.