Visualizzazione 0 filoni di risposte
Visualizzazione 0 filoni di risposte
- Devi essere connesso per rispondere a questo topic.
Email: info@wpitaly.it
Home › Forum › Plugin e temi di WP › Aggiungere Sticky a tema personale
CIao a tutti, ho un problema che no riesco a risolvere, probabilmente dovuto a qualcosa del mio codice sotto esposto che non funziona.
Voglio implementare gli sticky, articolo in evidenza nella HomePage ma ho un problema che non riesco a risolvere.
Se io ad un articolo metto la spunta ‘Mantenere l’articolo sempre in home page’ , funziona tutto a dovere, ma se non metto la spunta a nessun articolo mi visualizza tutti gli articoli.
Seguendo il codex inserisco in function.php il codice
$sticky = get_option( 'sticky_posts' );
$args = array(
'posts_per_page' => 1,
'post__in' => $sticky,
'ignore_sticky_posts' => 1
);
query_posts( $args );
if ( $sticky[0] ) {
// insert here your stuff... (linea 306)
}
ma a quel punto quando non c’è l’articolo mi aggiuinge il messaggio
<b>Notice</b>: Undefined offset: 0 in <b>/web/htdocs/www.somesay.it/home/semplice/wp-content/themes/semplice/functions.php</b> on line <b>306</b>.
All’interno della mia sidebar ho inserito questo codice per abilitare gli sticky
<div class="sticky">
<?php if (is_sticky()) echo 'Sticky post'; ?>
<?php query_posts(array('post__in'=>get_option('sticky_posts'))); ?><?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_excerpt() ;?>
<?php endwhile; ?>
</div>
Probabilmente l’errore è nel mio codice, potete aiutarmi
WPItaly - Copyright Creative Commons: CC BY-NC-SA 4.0