Forum Moderators: coopster

Message Too Old, No Replies

Quick php if - else clause help

         

Nosfer

8:46 pm on Jun 5, 2009 (gmt 0)

10+ Year Member



I've got a site based on wordpress and I would like to make an If-Else clause that show <the_content()> for a certain category and for all the rest it would show <the_excerpt()>

So it should be like

if (category=x) {the_content()}
else {the_excerpt)

now... my programming skills are so lame and don't really know how to code that. Any help would be really appreciated.

Thanks

max4

9:02 pm on Jun 5, 2009 (gmt 0)

10+ Year Member



You could define a function for the category you would like to display, then call it in your main document wherever you would like with the following:
[fixed]
if (isset($_GET['category'])) {
include 'category.php';
category();
} else {
include 'excerpt.php';
excerpt();
}
[/fixed]

Nosfer

9:05 pm on Jun 5, 2009 (gmt 0)

10+ Year Member



Oh, thanks but I think you misunderstood. I don't like to display the category, I would like to display the full length of all posts from a certain category and for posts from other categories i just want to insert the excerpt.

This should be done in the site's index.php from the wordpress loop and that's what I've thought until now:

<div class="entry">
<?php if ($cat==460 ) {the_content()}
else { echo limit_content($post->post_content, 70);
echo "...<a class='readmore' href='";
the_permalink();
echo "'>[Read More...]</a>";
}?>
</div>

don't really know if the right variable is $cat because it gets an error.

Nosfer

10:22 pm on Jun 5, 2009 (gmt 0)

10+ Year Member



problems solved :) thanks

<div class="entry">
<?php if (in_category(X)) the_content();
else the_excerpt(); ?>
</div>