Help Me “in_category” with echo? [closed]

If you are using in_category correctly, your code modified as per my comment should work. That is…

if (in_category($ct_portfoliocatid)) :
    include (TEMPLATEPATH . '/portfolio.php');
else :
endif;

You don’t need all those messy opening and closing PHP tags so I removed them and I don’t know why you have an else at all.

From the Codex for in_category:

Tests if the current post (or any specified post) is assigned to any
of the specified categories.

in_category() considers only the categories a post is directly
assigned to (the checked categories in Write/Edit Post panel), not the
parents of the assigned categories (but see Testing if a post is in a
descendant category below).

This tag can be used to test the current post within The Loop or
(since Version 2.7) outside the Loop during a single post request. You
can use it anywhere if you specify which post you want to test.

So, if that code is in the Loop (you did not supply the second parameter so it defaults to the current post in the Loop), and if the category is directly assigned to the post and not a parent category of a category assigned to the post, that code should work, and does work when I try it. Of course, $ct_portfoliocatid also has to be set correctly and I have no way to know if it is.

Again, your original code is badly broken but perhaps another issue is that you are not using the function correctly.

tech