php - 2 Classes and Filed in 1 Section
Get the solution ↓↓↓I have 2 different fields in different classes, which are displayed on the site in one section.
Only one of them is used at a time.
I am currently using this code:
<div class = "class2">
<? php the_sub_field ('filed2'); ?>
</div>
<div class = "class1">
<? php the_sub_field ('filed1'); ?>
</div>
Each has a different class, but both options are available. I want to make a condition.
If filed2 is used then class 2
And if filed1 is used then class 1
Right now the style of both is conflicting, and it doesn't fit. How to define this condition?
Answer
Solution:
You can make as follows :
<? php
if($field=='field1')
$class="class1";
else if($field=='field2')
$class="class2";
// here give $field a value
$field= 'field1'
?>
<div class = " <? php echo $class ?> ">
<? php the_sub_field ('$field'); ?>
</div>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: cannot add or update a child row: a foreign key constraint fails
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.