Support

Account

Home Forums General Issues list posts from relationship orderby category

Helping

list posts from relationship orderby category

  • Hello,
    I’m having trouble getting a relationship query sorted.
    Could someone help me?

    I have 2 CPTs articles and authors.
    In CPT Articles I have an ACF field to make the relationship between the articles and its authors. The authors have specific categories.

    On the article page, I can list all the evolved authors, but I also need to sort them by category.
    I would use author categories just to sort them, so they do not have to appear in the front end.

    <?php
    	$posts = get_field('autor', $autor->ID); 
    	$posts = wp_list_sort( $posts, array(
             'post_title' => 'ASC'
    	));
    	if( $posts ):
    		foreach( $posts as $post):
    			setup_postdata($post); ?>
    				<div class="featured">
    
    					<?php the_title(); //etc... ?>
    
    				</div>
    	<?php endforeach;
    		wp_reset_postdata();
    	endif;
    ?>

    I tried it in several ways, but my limitation in php prevents me from fully understanding the tutorials.
    I appreciate any help.

  • This reply has been marked as private.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.