Home › Forum › Plugin e temi di WP › Script Articoli correlati posizione sbagliata
-
AutorePost
-
-
5 Gennaio 2013 alle 15:39 #23476DoppiaJPartecipante
Salve a tutti! Sono sempre io! xD Questa volta il problema è molto semplice per chi conosce bene wordpress (non fa il caso mio xD)
allora su internet ho inserito trovato uno script per gli articoli correlati senza plug in.. quindi ho inserito il codice in single.php subito dopo the_content lo script funziona alla perfezione l’unico problema è che viene visualizzato dopo i commenti e non prima creando una struttura del tipo:
Articolo
Commenti
Articoli correlati
Io invece vorrei arrivare ad avere una struttura tipo:
Articolo
Articoli correlati
Commenti
Questo è il codice di single.php
<?php the_content('<center><h2>Continua a leggere...</h2></center>'); ?>
<!---Articoli Correlati--->
<?php $related_post = $post;
global $post;
$tags = wp_get_post_tags($post->ID);
if ($tags) { $tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=>5, // numero post correlati da visualizzare
'caller_get_posts'=>1 );
$related_query = new wp_query( $args );
if( $related_query->have_posts() ) { echo '<div id="articoli-correlati"><h3>Articoli correlati</h3>
- ';
<h2>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></h2>
while( $related_query->have_posts() ) { $related_query->the_post(); ?>
<?php } echo '
</div>';
}
}
$post = $related_post;
wp_reset_query();
?>
<!---Fine Articoli Correlati--->
Come potete vedere anche voi non c'è nessun richiamo ai commenti, ma secondo me i commenti sono contenuti in the_content c'è un modo per dividere il codice in modo da inserire tra Articolo e Commenti gli Articoli correlati?
Grazie mille in anticipo a tutti! -
5 Gennaio 2013 alle 16:39 #100100SteveAglAmministratore del forum
Come al solito hai pubblicato e non hai letto le istruzioni.. mancano alcune informazioni… indovina quali? Studia e ripubblica le info mancanti…
-
5 Gennaio 2013 alle 16:46 #100101DoppiaJPartecipante
Come al solito hai pubblicato e non hai letto le istruzioni.. mancano alcune informazioni… indovina quali? Studia e ripubblica le info mancanti…
Ciao! Scusami, ho dimenticato di dire una cosa fondamentale… disattivando tutti i plug in (in particolare quello di Facebook per i commenti) lo script è al posto giusto… Il problema sorge solo quando attivo tale plug in.
-
5 Gennaio 2013 alle 18:26 #100103SteveAglAmministratore del forum
Che si vede che manipola il content.. ergo non c’è soluzione almeno non banale.. se non quella di scrivere un plugin che manipoli a sua volta il content PRIMA del plugin di facebook… Ovviamente dirci che i commenti NON sono quelli di WP ma usi quelli di facebook pareva brutto eh? Sempre informazioni minimi mi raccomandi…
-
5 Gennaio 2013 alle 19:17 #100104elmaniseroPartecipante
Post e tempo sprecato Steve, dopo 10 minuti dal suo ultimo messaggio aveva già risolto ma si è ben guardato dal comunicarlo.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.