• Resolved morganfardo

    (@morganfardo)


    is ti possible to set different post meta to each category?

    i am trying:

    <?php if (in_category('economia')) {
    echo <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>
    } else {
    	<p class="meta">
    	  <span class="timr"><?php the_time('d F Y') ?></span>
    	  <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>
    } ?>

    but i got a “<” error…

    can anybody help me?

    thanks,

Viewing 8 replies - 1 through 8 (of 8 total)
  • 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 } ?>
    Thread Starter morganfardo

    (@morganfardo)

    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.

    Thread Starter morganfardo

    (@morganfardo)

    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 &rarr;[/lang_br][lang_es]Artículo Completo &rarr;[/lang_es][lang_en]Read the rest of this entry &rarr;[/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 &rarr;','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]&larr; Anterior[/lang_br][lang_es]&larr; Anteior[/lang_es][lang_en]&larr; Back[/lang_en]') ?>
        </div>
    
        <div class="alignright">
            <?php previous_posts_link('[lang_br]Próxima &rarr;[/lang_br][lang_es]Próxima &rarr;[/lang_es][lang_en]Next &rarr;[/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

    Thread Starter morganfardo

    (@morganfardo)

    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

    Thread Starter morganfardo

    (@morganfardo)

    thank iridiax… i found the problem… it was missing a ? inf front of a php

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘problem to set different post meta’ is closed to new replies.