Home › Forum › Plugin e temi di WP › problema con postnavlinks e loop multiplo
-
AutorePost
-
-
21 Dicembre 2009 alle 21:56 #12508toto80Partecipante
Sintentizzando, ho in home page questo
<?php
if (is_home()) {
$latest = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
$latest = str_replace('-', '', substr($latest, 0, 10));
query_posts('m=' . $latest . '&showposts=-1');
$wp_query->is_archive = false; $wp_query->is_home = false;
query_posts("cat=-6,-8,-16");
}
?>
<div id="primoarticolo">
<?php
$my_query = new WP_Query('showposts=1&cat=-6,-8,-16');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>
<h1>" title="<?php the_title(); ?>"><?php the_title(); ?></h1>
</div>
<?php if (have_posts()) : ?>
<?php $nr_post = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
<div id="post-<?php the_ID(); ?>" class="post">
<h1>" title="<?php the_title(); ?>"><?php the_title(); ?></h1>
<?php the_excerpt(); ?>
<?php edit_post_link('Modifica', '<p>', '</p>'); ?>
</div></div></div>
Visualizzo sempre gli stessi articoli sulle pagine 2-3 etc. Ho letto che dovrei utilizzare questa formula
query_posts($query_string . $args);
ma non riesco ad adattarla al codice che utilizzo.
Qualcuno mi aiuta?
grazie!!
-
28 Dicembre 2009 alle 14:28 #70319toto80Partecipante
Per chi come me avesse lo stesso problema, io l’ho deviato osservando la struttura del tema magazine-basic.
index.php:
t
p
-
28 Dicembre 2009 alle 14:53 #70320toto80Partecipante
index.php:
<?php get_header(); ?>
<?php
$options = get_option("widget_sideFeature");
$posts = get_option('uwc_number_posts');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if (is_active_widget('widget_myFeature')) {
$args = array(
'cat'=>'-'.$options,
'showposts'=>$posts,
'paged'=>$paged,
);
} else {
$args = array(
'showposts'=>$posts,
'paged'=>$paged,
);
}
if(!get_option('uwc_number_posts')) {
$args = array(
'showposts'=>15,
'paged'=>$paged,
);
}
$x = 1;
query_posts($args);
?>
<?php
if(!stristr($_SERVER,'/page/')) {
if(get_option('uwc_latest_story') == "on") { echo '<h5 class="latest">'.__('Latest Story', "magazine-basic").'</h5>'; }
if(get_option('uwc_post_layout') == 1) { include (TEMPLATEPATH.'/option1.php'); }
elseif(get_option('uwc_post_layout') == 2) { include (TEMPLATEPATH.'/option2.php'); }
elseif(get_option('uwc_post_layout') == 4) { include (TEMPLATEPATH.'/option4.php'); }
else { include (TEMPLATEPATH.'/option3.php'); }
} else {
include (TEMPLATEPATH.'/option1.php');
}
?>
<?php
if(function_exists('pagination')) { pagination(); }
?>
<?php get_footer(); ?>
creo 4 file, option1.php option2.php option3.php e option4.php
option3 è l'home page mentre option1 pagina 2,3,4 etc.
In option1 ho messo un loop funzionante ed ora è ttutto ok!
saluti
-
29 Dicembre 2009 alle 16:11 #70341gollum1Partecipante
è sufficiente usare il parametro offset di querypost, spostandoti di tanti articoli quanto è il risultato del numero di pagine che stai visualizzando moltiplicato per il numero di post che stanno in ogni pagina.
il numero della pagina te lo prendi dell’url, il numero di articoli è una variabile di wp (che usi anche in query_post).
Byez
—
Gollum1
-
20 Aprile 2010 alle 15:46 #72873toto80Partecipante
Scusate ma ho ancora difficoltà e non ne vengo a capo:
se ho l’home page divisa in due colonne dove in ognuna prendo i post da una determinata categoria, come faccio a far funzionare la paginazione?
global $post;
$myposts = get_posts(‘numberposts=8&category=1’);
foreach($myposts as $post) :
setup_postdata($post);
-
20 Aprile 2010 alle 17:13 #72879SteveAglAmministratore del forum
Dipende quale delle due colonne deve paginare… entrambe non puoi farle paginare almenonon ina aniera auomatica…
-
20 Aprile 2010 alle 17:32 #72880toto80Partecipante
Ciao SteveAgl e grazie.
Dovrei paginare tutte e due le colonne, ma sull’url /page/2 /page/3 /page/4 etc.
ho un plugin che mi stampa la paginazione pagine:1 2 3 4 5 etc.
-
22 Aprile 2010 alle 7:57 #72914toto80Partecipante
Aiuto perfavore… non riesco a capire se è una cosa fattibile.
Si può paginare avendo su due colonne che prendono i post da due categorie diverse?
-
22 Aprile 2010 alle 10:23 #72917SteveAglAmministratore del forum
Non in maniera automatica ma scrivendo codice per gestire le paginazioni nelle varie query_posts… dipende dal tuo livello di capacità php
-
22 Aprile 2010 alle 14:01 #72922toto80Partecipante
Ho scarsa conoscenza di php.
Devo aggiungere delle funzioni su functions.php o mi basta modificare i due loop?
Ho guardato invano guide e forum..
grazie per l’aiuto
-
22 Aprile 2010 alle 14:49 #72924toto80Partecipante
Risolto:
<?php
$catname = news;
$wp_query = new WP_Query();
$wp_query->query(‘category_name=’.$catname. ‘&offset=1′ .’&showposts=5′.’&paged=’.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
grazie a tutti
-
22 Aprile 2010 alle 15:52 #72926toto80Partecipante
<?php
$catname = news;
$wp_query = new WP_Query();
$wp_query->query(‘category_name=’.$catname. ‘&showposts=5′.’&paged=’.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
senza offset!!!
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.