Created
October 22, 2022 12:24
-
-
Save l00f00/53e64f417e2679e7afe3832e11243135 to your computer and use it in GitHub Desktop.
metabox relationships fileds get all the posts related based on matching relationship
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$getartist = new WP_Query( [ | |
'relationship' => [ | |
'id' => 'opera_artist_relationship', | |
'from' => get_the_ID(), | |
], | |
'nopaging' => true, | |
] ); | |
while ( $getartist->have_posts() ) : $getartist->the_post(); | |
?> | |
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> | |
<?php | |
$getallartworks = new WP_Query( [ | |
'relationship' => [ | |
'id' => 'opera_artist_relationship', | |
'to' => get_the_ID(), | |
], | |
'nopaging' => true, | |
] ); | |
while ( $getallartworks->have_posts() ) : $getallartworks->the_post(); | |
?> | |
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> | |
<?php | |
endwhile; | |
wp_reset_postdata(); | |
endwhile; | |
wp_reset_postdata(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment