I would like to create a custom query loop to display data depending on the current post title.
Pseudo-code:
if post title = custom filed
Show related content
I have a page called artists made up of custom fields and I would like to show the discography for that artist. By pulling only the posts with the artists name from the discography posts which are in another custom post type.
I found this page which is close but not quite right.
I have a custom post type called discography, and within this post type I have a custom field called dis_artist.
I am stuck being able to say if the current artist "post title" = "dis_artist" then show other data. How can I do that?
Hi I tried but Im not sure I have the right syntax. This piece of code sits within the current post loop
<?php
$args = array( 'post_type' => 'discography', 'posts_per_page' => -1 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
if ( get_the_title() === get_post_meta( get_the_ID(), "dis_artist", true ) ) { ?>
<?php the_title(); ?>
<?php } ?>
<?php endwhile; ?>