Home › Forum › Plugin e temi di WP › Loop e cambio pagina
-
AutorePost
-
-
4 Gennaio 2009 alle 1:23 #8969bannedPartecipante
Ciao, e grazie per l’attenzione,
Cercavo di creare una pagina da una categoria,
ho seguito le istruzioni per la creazione di un loop sul vostro wiki qui
ed ho inserito prima del loop del mio template il codice che segue,
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=1&posts_per_page=10&paged=$paged');?>
preso da questa discussione: qui
a primo impatto sembra funzionare, ma in defintiva al cambio di pagina mi ricarica sempre il primo articolo:
es dominio.it/frutta/banane/ parte con il caricamento del primo articolo e arriva al 10 correttamente
dominio.it/frutta/banane/page/2 invece di partire con l'11 articolo della categoria riparte con il primo
premetto che ho poi creato una seconda pagina template con un loop decisamente piu semplice (base) di quello del mio tema che è fortemente personalizzato e il problema persiste.
p.s. il loop della mia pagina template di base (page.php) con le pagine di categoria /category/banane/ funziona (il cambio pagina)
per il momento ho risolto cosà¬:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=1&posts_per_page=50&paged=$paged');?>
lo so è ridicolo portare i post a 50 x pagina ma non avevo altre intuizioni
Grazie per l'aiuto,
Antonio.
-
4 Gennaio 2009 alle 21:10 #60832gollum1Partecipante
Mi ci sono trovato pure io nella stessa situazione…
posts_per_page dovrebbe gestire l’offset, ma anche per me non so per quale motivo non funzionava, allora ho escogitato questo strattagemma:
ho eliminato posts_per_page, e al suo posto ho usato direttamente il parametro offset, prendendo il numero della pagina a cui mi trovo, e moltiplicandolo per il numero di post per pagina… e cosଠfunziona a meraviglia…
Byez
—
Gollum1
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.