Use this basic format instead and get rid of the echo:
<?php if (is_category('economia')) { ?>
economia code here
<?php } else { ?>
else code here
<?php } ?>
Hi iridiax!
thanks for your help… but i had some problems…
when i try this code:
<?php if (is_category('economia')) { ?>
<p class="meta">
<span class="user">Autor: <?php the_author() ?> </span>
<span class="catr">Categoria: <?php the_category(', ') ?></span>
<?php edit_post_link('Editar', '<span class="editr">', '</span>'); ?>
</p>
<?php } else { ?>
<p class="meta">
<span class="timr"><?php the_time('d F Y') ?></span>
<span class="user"><?php _e('[lang_br]Autor: [/lang_br][lang_es]Autor: [/lang_es][lang_en]Author: [/lang_en]'); ?><?php the_author_posts_link(); ?></span>
<span class="catr"><?php _e('[lang_br]Categoria: [/lang_br][lang_es]Categoria: [/lang_es][lang_en]Category: [/lang_en]'); ?><?php the_category(', ') ?></span>
<?php edit_post_link('Editar', '<span class="editr">', '</span>'); ?>
</p>
<php } ?>
it start giving a lot of errors like in the T_ENDWHILE that ends while have post…
do you have any idea?
thanks
Where are you putting this code? Maybe what you need is in_category instead of is_category.
i´m putting in the index, but i want to use it in single and archive as well…
with in_category it didn´t worked as well…
here is my index page:
<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) : ?>
<?php query_posts("cat=-28"); ?>
<?php query_posts("cat=-38"); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php if (is_category('economia')) { ?>
<p class="meta">
<span class="user"><?php _e('[lang_br]Autor: [/lang_br][lang_es]Autor: [/lang_es][lang_en]Author: [/lang_en]'); ?><?php the_author_posts_link(); ?></span>
<span class="catr"><?php _e('[lang_br]Categoria: [/lang_br][lang_es]Categoria: [/lang_es][lang_en]Category: [/lang_en]'); ?><?php the_category(', ') ?></span>
<?php edit_post_link('Edit', '<span class="editr">', '</span>'); ?>
</p>
<?php } else { ?>
<p class="meta">
<span class="timr"><?php the_time('d F Y') ?></span>
<span class="user"><?php _e('[lang_br]Autor: [/lang_br][lang_es]Autor: [/lang_es][lang_en]Author: [/lang_en]'); ?><?php the_author_posts_link(); ?></span>
<span class="catr"><?php _e('[lang_br]Categoria: [/lang_br][lang_es]Categoria: [/lang_es][lang_en]Category: [/lang_en]'); ?><?php the_category(', ') ?></span>
<?php edit_post_link('Edit', '<span class="editr">', '</span>'); ?>
</p>
<php } ?>
<div class="entry">
<div id="HOTWordsTxt" class="HOTWordsTxt">
<?php the_excerpt('[lang_br]Artigo Completo →[/lang_br][lang_es]Artículo Completo →[/lang_es][lang_en]Read the rest of this entry →[/lang_en]'); ?>
<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
</div>
</div>
<?php if(function_exists('the_tags')): ?>
<div class="tags"><?php the_tags('Tags: ', ', ', ''); ?></div>
<?php endif; ?>
<p class="postmeta">
<span class="commr"><?php comments_popup_link('Comente este artigo / Comment this article / Comente este artículo →','Comentário (1) / Comment (1) / Comentario (1)','Comentários (%) /Comments (%) / Comentarios (%)'); ?></span>
</p>
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft">
<?php next_posts_link('[lang_br]← Anterior[/lang_br][lang_es]← Anteior[/lang_es][lang_en]← Back[/lang_en]') ?>
</div>
<div class="alignright">
<?php previous_posts_link('[lang_br]Próxima →[/lang_br][lang_es]Próxima →[/lang_es][lang_en]Next →[/lang_en]') ?>
</div>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
thanks for your help…
You need in_category instead of is_category, and you must use category ID for in_category. Check out the following page for instructions on how to use it:
http://codex.wordpress.org/Template_Tags/in_category
i tryed with in_category and got the same error…
Parse error: syntax error, unexpected T_ENDWHILE in /home/informee/public_html/wp-content/themes/Prosumer/index.php on line 78
but i dont understand why…
Your code has errors like with your query_posts. Here are instructions on how to use query_posts:
http://codex.wordpress.org/Template_Tags/query_posts
Also review using the loop:
http://codex.wordpress.org/The_Loop
thank iridiax… i found the problem… it was missing a ? inf front of a php