pobliska
pobliska

Reputation: 247

Html code inside php wordpress statement

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>

Upvotes: 0

Views: 111

Answers (1)

swiss_blade
swiss_blade

Reputation: 541

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(); 
}
?>

Upvotes: 4

Related Questions