Post random wordpress
-
Ho apportato le modifiche per evitare che mi appaia nei post consigliati anche il post che si sta leggendo ma non funziona.
Questo il codice:
<!-- start random post --> <p class="random_post_whit_thumbnail"> <strong>Aspetta, c'è dell'altro:</strong></p> <?php $current_post=get_the_id(); $args = array( 'orderby' => 'rand', 'posts_per_page' => '4', 'Post__not_in'=> array($current_post) ); // The Query $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php if( has_post_thumbnail() ) : ?> <div class="move_thumb_down"> <a class="link_random_post" href="<?PHP the_permalink(); ?>"><?php the_title(); ?></a> <?php echo get_the_post_thumbnail($post_id, 'thumbnail', array('class' => 'thumb_random_post')); ?> </div> <?php endif; endwhile; else : // no posts found endif; /* Restore original Post Data */ wp_reset_postdata(); ?> <!-- end random post -->Ho sbagliato qualcosa?
Grazie -
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
