Support » Plugins » ACF Relationship Field

  • Gelöst j_spaceman

    (@nothinghalosix)


    hallo,

    verwende das relationship field von ACF um mir die von einem Autor erstellten Beiträge anzeigen zu lassen. Allerdings werden mir die nach Datum aufsteigend georndet. möchte die aber absteigend geordnet haben. Mir fehlt da jetzt irgendwie der Ansatz

    <?php
    
     $posts = get_field('post_category_relationship');
    
     if( $posts ): ?>
         <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
         <div class="mt-6">
           <div class="flex flex-wrap border border-grey-lighter mb-6 rounded shadow-lg relative">
             <div class="w-1/3 sm:w-full sm:pr-0">
               <?php setup_postdata($post); ?>
               <a class="-mb-1 block" href="<?php the_permalink(); ?>">
                <?php $post_img = get_imgproxy_url(get_the_post_thumbnail_url() , 400, 269, 'fill' , 'sm'); ?>
                <img src="<?php echo $post_img; ?>" alt="" class="w-full lg:rounded-l md:rounded-tl sm:rounded-t">
              </a>
             </div>
             <div class="w-2/3 sm:w-full p-4">
              <a  class="no-underline hover:underline text-secondary" href="<?php the_permalink(); ?>" title="weiterlesen">
                <h2 class="mb-4"><?php the_title(); ?></h2>
              </a>
              <?php
                $excerpt = get_field('excerpt');
                echo '<div class="mb-4"><p>';
                echo $excerpt;
                echo ' [...]</p></div>'
              ?>
    
              <div class="absolute read-more-button">
                <a class="bg-secondary text-white no-underline px-4 py-2 hover:bg-secondary-light font-bold" href="<?php the_permalink(); ?>" title="Read more">zum Beitrag</a>
              </div>
    
              <p><i class="fal fa-calendar mr-2" aria-hidden="true"></i><?php echo get_the_date(); ?> |
              <?php if( have_rows('choose_agent_section')): while ( have_rows('choose_agent_section')) : the_row();
                  // set up post object
                    $post_object = get_sub_field('choose_agent');
                    if( $post_object ) :
                    $post = $post_object;
                    setup_postdata($post);
                  ?>
                   <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
    
                <?php endif; endwhile; ?>
              <?php endif; ?>
    
              <div class="tags mb-4">
                <p><i class="fal fa-tags"></i><?php the_tags(' '); ?></p>
              </div>
    
            </div>
           </div>
         </div>
         <?php endforeach; ?>
         <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
     <?php endif; ?>

    danke

Ansicht von 1 Antwort (von insgesamt 1)
Ansicht von 1 Antwort (von insgesamt 1)
  • Das Thema „ACF Relationship Field“ ist für neue Antworten geschlossen.