Home › Forum › WP e Accessibilità › Dubbio template
-
AutorePost
-
-
4 Luglio 2008 alle 9:24 #7184LuiginoPartecipante
Ciao a tutti,
ho un dubbio con un template….
dunque ho creato un template associandolo ad una pagina pagina.php, copiandolo da index.php in modo da poter leggere tutti i post e filtrarli per categoria cosicché in questa pagina.php posso vedere solo i post contrassegnati in una certa categoria… come template funziona… ma quando fa il ciclo di Loop pare che non recepisca nessun post… perché?…
Il pezzo di codice che c’è nel template in questione è questo:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<span> Prova lettura template catalog </span>
<?php if ( in_category(‘3’) ) { ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>
<div class=”post-title”>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></div>
<div class=”post-text”>
<?php the_content(‘Read the rest of this entry »’); ?>
</div>
<div class=”post-date”>
<small>Inserito da <?php the_author() ?>, <?php the_time(‘j F Y’) ?><br/></small></div>
</div>
<?php } ?>
<?php endwhile; ?>
Da un punto di vista logico dovrebbe funzionare perché con the_post() dovrebbe andare a prendere tutti i post dalla tabella wp_posts dovunque essa sia dato che è una funzione di chiamata…. mah….ditemi voi…. può essere che sono ignorante e mi è sfuggito qualcosa…
Grazie in anticipo per l’eventuale dritta!!!
Ciao!
Luigi
-
4 Luglio 2008 alle 11:18 #55540ArturoPartecipante
prova solo con:
<?php $recent = new WP_Query(“cat=1&showposts=2”); while($recent->have_posts()) : $recent->the_post();?>
poi ci metti il titolo, e poi il content. su cat=X cambi l’id della categoria e showposts=X metti il numero di post per quella categoria che vuoi che escano.
-
4 Luglio 2008 alle 11:33 #55541LuiginoPartecipante
Ciao Arturo,
intendi cioè sostituire questa riga:
<?php while (have_posts()) : the_post(); ?>
con quella che hai detto tu visto che vedo un while()?….
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.