0

On posts with category "kursy" i need to display content in tabs. In any others posts only entry content. I have problem to insert the html (with some php) into the if statement.

    <?php 
if ( in_category( 'kursy' )) {
    echo " HTML with tabs ";    //I need to insert the html here
} else {
 echo get_the_content(); 
}
?>

My html with tabs:

<div id="tabs">
<ul>
<li><a href="#tabs-1">About</a></li>
<li><a href="#tabs-2">Date</a></li>
<li><a href="#tabs-3">Gallery</a></li>
<li><a href="#tabs-4">Targets</a></li>
</ul>
<div id="tabs-1">
<?php echo get_the_content(); ?>
</div>
<div id="tabs-2">
 <?php echo get_post_meta($post->ID, 'date', true); ?>
</div>
<div id="tabs-3">
<td><?php echo get_post_meta($post->ID, 'gallery', true); ?></td> 
</div>
<div id="tabs-4">
    <td><?php echo get_post_meta($post->ID, 'targets', true); ?></td> 
</div>
</div>

1 Answer 1

4

Use this method:

<?php 
if ( in_category( 'kursy' )) { ?>

<div id="tabs">
<ul>
<li><a href="#tabs-1">About</a></li>
<li><a href="#tabs-2">Date</a></li>
<li><a href="#tabs-3">Gallery</a></li>
<li><a href="#tabs-4">Targets</a></li>
</ul>
<div id="tabs-1">
<?php echo get_the_content(); ?>
</div>
<div id="tabs-2">
 <?php echo get_post_meta($post->ID, 'date', true); ?>
</div>
<div id="tabs-3">
<td><?php echo get_post_meta($post->ID, 'gallery', true); ?></td> 
</div>
<div id="tabs-4">
    <td><?php echo get_post_meta($post->ID, 'targets', true); ?></td> 
</div>
</div>

<?php } else {
 echo get_the_content(); 
}
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.