Wsparcie » Używanie i konfiguracja WordPressa » Wyświetlanie 3 następnych postów.

  • Rozwiązano blaku

    (@blaku)


    Siemka.
    Jak wyświetlić 3 następne posty?
    Głównie interesuje mnie jakaś funkcja, którą po prostu pobiorę miniaturki z nich wraz z linkami.
    Czyli np.: Wchodzę do postu pierwszego i pokazują mi się miniaturki 2, 3, 4. Wchodzę do 2 i pokazują mi się miniaturki 3, 4, 5.
    O coś takiego chodzi.
    Pomożecie?

Viewing 2 replies - 1 through 2 (of 2 total)
  • wrzuc w miejsce gdzie chcesz wyswietlac nawigację obrazkową poniższy kod, oczywiście musisz sobie ostylować

    <?php
    $postlist = get_posts( 'orderby=menu_order&sort_order=asc' );
    $posts = array();
    foreach ( $postlist as $post ) {
       $posts[] += $post->ID;
    }
    
    $current = array_search( get_the_ID(), $posts );
    $prevID = $posts[$current-1];
    $nextID = $posts[$current+1];
    $prevsecondID = $posts[$current-2];
    $nextsecondID = $posts[$current+2];
    $prevthridID = $posts[$current-3];
    $nextthridID = $posts[$current+3];
    ?>
    
    <div>
    <div class="alignleft">
    <?php
    if ( !empty( $prevthridID ) ): ?>
    	<a>"
      title="<?php echo get_the_title( $prevthridID ); ?>">
      <?php if ( has_post_thumbnail() ) {
    	the_post_thumbnail(array(100,100));
    } ?>
    </a>
    <?php endif;
    if ( !empty( $prevsecondID ) ): ?>
    	<a>"
      title="<?php echo get_the_title( $prevsecondID ); ?>">
      <?php if ( has_post_thumbnail() ) {
    	the_post_thumbnail(array(100,100));
    } ?>
    </a>
    <?php endif;
    if ( !empty( $prevID ) ): ?>
    <a>"
      title="<?php echo get_the_title( $prevID ); ?>">
      <?php if ( has_post_thumbnail() ) {
    	the_post_thumbnail(array(100,100));
    } ?>
    </a>
    
    <?php endif ?>
    </div>
    <div class="alignright">
    <?php
    if ( !empty( $nextID ) ): ?>
    <a>"
     title="<?php echo get_the_title( $nextID ); ?>">
      <?php if ( has_post_thumbnail() ) {
    	the_post_thumbnail(array(100,100));
    } ?>
    </a>
    <?php endif;
    if ( !empty( $nextsecondID ) ): ?>
    <a>"
     title="<?php echo get_the_title( $nextsecondID ); ?>">
      <?php if ( has_post_thumbnail() ) {
    	the_post_thumbnail(array(100,100));
    } ?>
    </a>
    <?php endif;
    if ( !empty( $nextsecondID ) ): ?>
    <a>"
     title="<?php echo get_the_title( $nextthridID ); ?>">
      <?php if ( has_post_thumbnail() ) {
    	the_post_thumbnail(array(100,100));
    } ?>
    </a>
    
    <?php endif; ?>
    </div>
    </div>
    Thread Starter blaku

    (@blaku)

    Działa! Wielkie dzięki! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • Temat ‘Wyświetlanie 3 następnych postów.’ jest zamknięty na nowe odpowiedzi.