[Risolto] Guide Recenti su barra laterale
-
Grazie per avermi risposto, ho fatto come mi hai detto ma non mi visualizza solo gli articoli della categoria che voglio ma di tutte.:x
Ho scritto così nel codice
$today = current_time('mysql', 1); if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 10")): ?> <h2><?php _e("Guide"); ?><span><?php _e("Recenti"); ?></span></h2> <ul class="splittedlists"> <?php foreach ($recentposts as $post) { if ($post->post_title == '' AND in_category3) $post->post_title = sprintf(__('Post #%s'), $post->ID); echo "<li><a href='".get_permalink($post->ID)."'>"; the_title(); echo '</a></li>'; }?> </ul>spero che mi sappia aiutare
-
prova così
<div> <?php $today = current_time('mysql', 1); if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 10")): ?> <h2><?php _e("Guide"); ?><span><?php _e("Recenti"); ?></span></h2> <ul class="splittedlists"> <?php foreach ($recentposts as $post) { if ($post->post_title == '' AND in_category('3')) $post->post_title = sprintf(__('Post #%s'), $post->ID); echo "<li><a href='".get_permalink($post->ID)."'>"; the_title(); echo '</a></li>'; }?> </ul> <?php endif; ?> </div> -
-
allora mi sa che il plugin non utilizza le funzioni base di wp, sa quindi da dover riscrivere un bel po' il plugin per ottenere quello che vuoi.
praticamente il problema è che per ogni post non è salvato nella stessa tabella dove è contenuto il post quali siano le sue categorie, ma su una seconda tabella...

potresti provare una cosa del genere però
<div> <?php $today = current_time('mysql', 1); if ( $ids = $wpdb->get_results("SELECT post_id FROM $wpdb->post2cat WHERE category_id ='3' ORDER BY post_id DESC LIMIT 10")) { foreach($ids as $id) { if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' AND ID='$id->post_id' ORDER BY post_date DESC LIMIT 10")): ?> <h2><?php _e("Guide"); ?><span><?php _e("Recenti"); ?></span></h2> <ul class="splittedlists"> <?php foreach ($recentposts as $post) { if ($post->post_title == '' AND in_category('3')) $post->post_title = sprintf(__('Post #%s'), $post->ID); echo "<li><a href='".get_permalink($post->ID)."'>"; the_title(); echo '</a></li>'; }?> </ul> <?php endif; } }?> </div> -
-
-
Vai nel mio sito pccyber.altervista.org e vedi come si presenta ora...comunque mi fa apparire prima le guide + vekki e andando sotto mi fa vedere le guide più recenti, dovrebbe essere il contrario.
-
-
-
-
L'ho utilizzato il codice ma mi visualizza ogni articolo su una sezione, per capire bene basta che vedi il mio sito http://pccyber.altervista.org/
-
-
-
-
-
Grandissimo, ora funziona alla perfezione
Posto il codice completo corretto, forse a qualche utente gli servirà
<div> <h2><?php _e("Guide"); ?><span><?php _e("Recenti"); ?></span></h2> <?php $today = current_time('mysql', 1); if ( $ids = $wpdb->get_results("SELECT post_id FROM $wpdb->post2cat WHERE category_id ='3' ORDER BY post_id DESC LIMIT 10")) { foreach($ids as $id) { if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' AND ID='$id->post_id' ORDER BY post_date DESC LIMIT 10")): ?> <ul class="splittedlists"> <?php foreach ($recentposts as $post) { if ($post->post_title == '' AND in_category('3')) $post->post_title = sprintf(__('Post #%s'), $post->ID); echo "<li><a href='".get_permalink($post->ID)."'>"; the_title(); echo '</a></li>'; }?> </ul> <?php endif; } }?> </div>Grazie ancora

-
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi


