Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

eliasfaical

Exibir POST em destaque

Recommended Posts

Estou criando um site onde na minha pagina inicial será exibido os últimos 5 posts de categorias aleatórias, o último post será em destaque diferente dos demais exibidos (uma imagem maior, título maior, etc). Minha dúvida é como faço para diferenciar o post em destaque dos outros? Segue a baixo o loop que fiz.

 

<ul id="listNoticias">
<?php query_posts("showposts=5"); ?>
 <?php if (have_posts()): while (have_posts()) : the_post();?>    
     <li class="newsDestaque">
       <?php $imgdestaque = get_post_meta($post->ID, 'imgdestaque', true); ?>
       <img src="<?php echo $imgdestaque ?>" alt="<?php the_title(); ?>" />
       <span><?php $category = get_the_category(); echo $category[0]->cat_name; ?></span>
       <h2><?php the_title(); ?></h2>
       <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_excerpt(); ?> </a>
     </li>
   <?php endwhile; else:?>
 <?php endif;?>  
</ul>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá Rogerio, obrigado pela dica! conseguir resolver o probelma usando offset

no caso meu loop ficou assim:

 

<ul id="catNoticias">

<?php
//lista todos os posts de uma categoria/tags especifica dentro da page. 
$categ = $_SERVER['REQUEST_URI'];
function geraUrlLimpa2($categ){
 $categ = eregi_replace('\/','',$categ);
 return ($categ);
}
?>
    <li class="newsDestaque">
 <?php query_posts('category_name='.$categ.'&paged=$paged&showposts=1'); ?>

    <?php if (have_posts()): while (have_posts()) : the_post();?>    
	   <?php $imgdestaque = get_post_meta($post->ID, 'imgdestaque', true); ?>
          <img src="<?php echo $imgdestaque ?>" alt="<?php the_title(); ?>" />
        <span><?php $category = get_the_category(); echo $category[0]->cat_name; ?></span>
        <h2><?php the_title(); ?></h2>
        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_excerpt('30'); ?> </a>  
    <?php endwhile; else:?>
    <?php endif;?>  
    </li>

    <li class="newsOutras" style="margin:0;">
 <?php query_posts('category_name='.$categ.'&paged=$paged&showposts=1&offset=1'); ?>     
 <!--<'?php query_posts("showposts=1&category_name=noticias&offset=1"); ?>-->
    <?php if (have_posts()): while (have_posts()) : the_post();?>    
       <span><?php $category = get_the_category(); echo $category[0]->cat_name; ?></span>
	   <?php $imgmenor = get_post_meta($post->ID, 'imgmenor', true); ?>
          <img src="<?php echo $imgmenor ?>" alt="<?php the_title(); ?>" />
       <h2><?php the_title(); ?></h2>
       <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_excerpt(); ?> </a>  
    <?php endwhile; else:?>
    <?php endif;?>  
    </li>  
</ul>

 

a

<li>

que está com o id destaque eu não preciso do offset, pois ela sempre vai ser 0 e as outras eu coloco a quantidade de post e o offset para dizer a partir de quanto ele vai começar a contar, no caso 1.

 

obrigado!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Muito interessante.

 

E se eu quiser colocar um link dinamico com NOME DO BLOG + TITULO do ultimo post na capa de outro site.

 

Qual a maneira certa pra fazer isto? Alguém pode me ajudar?

 

Envie a resposta para senawebdesign@yahoo.com.br por favor. Obrigado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.