← WordPress

Alterar ordem dos artigos da página inicial

Lida 4740 vezes

Offline

nandotx 
Membro
Mensagens 1012 Gostos 1
Feedback +9

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Mobile User Windows User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3

Normalmente o WordPress mostra os artigos mais recentes no topo e os mais antigos no fim.

Precisava de inverter isto, alguém me sabe dizer uma maneira simples de o fazer? Ou seja, mostrar os artigos antigos primeiro, no topo da lista...
Offline

Zompixau 
Membro
Mensagens 511 Gostos 0
Feedback +1

Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Se fores ás configurações o WordPress acho que tens isso.
Offline

Nuno 
Administrador
Mensagens 7780 Gostos 216
Feedback +2

Troféus totais: 42
Trófeus: (Ver todos)
100 Poll Votes Level 7 Search Mobile User Level 6 Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes

no fichero dos posts, será index.php, home.php, archive.php, etc

<?php
query_posts( qualer_coisa &order=ASC');
if (have_posts()) : ?>
Offline

nandotx 
Membro
Mensagens 1012 Gostos 1
Feedback +9

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Mobile User Windows User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3

no fichero dos posts, será index.php, home.php, archive.php, etc

<?php
query_posts( qualer_coisa &order=ASC');
if (have_posts()) : ?>

Esta era a solução que eu pensava, mas o problema é que não tem isso do "order" no meu theme.
Offline

Diogo Pinto 
Administrador
Mensagens 4400 Gostos 371
Feedback +4

Troféus totais: 37
Trófeus: (Ver todos)
Avatar Search Level 6 Linux User Mobile User Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes

tens que adicionar nandotx...
Offline

Pedro Lopes 
Beta tester
Mensagens 3568 Gostos 18
Feedback +6

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Esta era a solução que eu pensava, mas o problema é que não tem isso do "order" no meu theme.
Adiciona. Mostra ai a parte do "query".
Offline

nandotx 
Membro
Mensagens 1012 Gostos 1
Feedback +9

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Mobile User Windows User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3

Está assim:

Código: [Seleccione]
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Offline

Pedro Lopes 
Beta tester
Mensagens 3568 Gostos 18
Feedback +6

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Está assim:

Código: [Seleccione]
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Tem de ter uma query antes! :S
Ou então get_posts().
Offline

nandotx 
Membro
Mensagens 1012 Gostos 1
Feedback +9

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Mobile User Windows User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3

Só se for isto:

Código: [Seleccione]
<?php $count 1?><?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post();
$thumb get_post_meta($post->ID'imagem'$single true); ?>
Offline

Pedro Lopes 
Beta tester
Mensagens 3568 Gostos 18
Feedback +6

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Tenta assim:

Código: [Seleccione]
<?php while (have_posts('order=ASC')) : the_post();
Offline

nandotx 
Membro
Mensagens 1012 Gostos 1
Feedback +9

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Mobile User Windows User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3

Não rola.
Offline

Nuno 
Administrador
Mensagens 7780 Gostos 216
Feedback +2

Troféus totais: 42
Trófeus: (Ver todos)
100 Poll Votes Level 7 Search Mobile User Level 6 Super Combination Combination Topic Starter 50 Poll Votes 10 Poll Votes



Código: [Seleccione]
<?php if (have_posts($query_string '&orderby=title&order=asc')) : while (have_posts()) : the_post(); ?>
Offline

nandotx 
Membro
Mensagens 1012 Gostos 1
Feedback +9

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Mobile User Windows User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3

Esse código era da página "page.php". Troquei de ficheiro ao fazer a pesquisa e não me apercebi...

Fica aqui o código da index:

Código: [Seleccione]
<?php get_header(); ?>

<div class="main_table">
<div class="main_table_row">
<div class="left_1"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/spacer.gif" alt="" align="top" style="width:1px; height:1px"/></div>


<div class="main_cent">
<div class="co_name_bg">
<div class="co_name">
</div>
</div>


<div class="head_bg">
<div class="table2">
<div class="table_row">
<div class="left2">

<?php $count 1?><?php if (have_posts()) : ?>


<?php while (have_posts()) : the_post();
$thumb get_post_meta($post->ID'imagem'$single true);

 
?>



<table width="589" border="0" cellspacing="0" cellpadding="0" style="margin-top:0px;">
  <tr>
              <td valign="top">
                <!-- BEGIN left -->
                <div class="left_box">

<div class="content_left_top">
</div>
<div class="content_left_bg">
<?php // if there's a thumbnail
if($thumb !== '') { ?>

<p>
<img src="<?php echo $thumb?>" width="180" height="130" />
</p>
<?php // end if statement

// if there's not a thumbnail
else { echo ''; } ?>

<div class="content_left">

             
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="meta1">

</div>
<div style="margin:5px 0 10px 0; border-top: 1px dashed #fff;"></div>
<?php
$content get_the_excerpt('',FALSE,'');
$content apply_filters('the_content'$content);
$content str_replace(']]>'']]>'$content);
echo substr($content,0,290);
?>
&hellip;

</div>
</div>

<div class="content_left_bottom">
</div>

<!-- end post -->


</div>

<!-- END left -->

</td>
              <td valign="top">



</td>
  </tr>
</table>
<?php if ($count == 1) : ?>
<div align="center" style="margin-bottom:8px;">
<?php include (TEMPLATEPATH "/post_ad.php"); ?>
</div>
<?php endif; $count++; ?>

  <?php endwhile; ?>
<?php else : ?>

          <h2>ERRO - Nenhum artigo encontrado</h2>

<?php endif; ?>   
<div class="wp-pagenavi">
<?php if (function_exists('wp_pagenavi')) : ?>
<?php wp_pagenavi(); ?>
<?php else : ?>
<?php next_posts_link('&laquo; Página Anterior'); ?>
<?php previous_posts_link('Página Seguinte &raquo;'); ?>

<?php endif; ?>
</div>



<div class="comment">
</div>

</div>
<div class="right2">
</div>
</div>
</div>
</div>




</div>
<div  class="main_left">
<?php include (TEMPLATEPATH "/sidebar.php"); ?>
  </div>

<div class="right_1"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/spacer.gif" alt="" align="top" style="width:1px; height:1px"/></div>
</div>
</div>

<?php get_footer(); ?>
</div>
</div></div>
</body>
</html>
Offline

Pedro Lopes 
Beta tester
Mensagens 3568 Gostos 18
Feedback +6

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Tenta adicionar a query antes de while (have_posts()) : the_post();

Código: [Seleccione]
query_posts('orderby=date&order=asc');
Offline

nandotx 
Membro
Mensagens 1012 Gostos 1
Feedback +9

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Mobile User Windows User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3

Para não andar a mexer no código, encontrei este plugin que faz o que pretendo:

AStickyPostOrderER


Obrigado a todos pela disponibilidade!