Forum Replies Created

Viewing 1 replies (of 1 total)
  • If someone still struggles with this one, here’s one way:

    First query all posts that meet your other criteria. After that, in the following while loop check if the value is an array or a string (I had a nice mix after fooling around with Advanced Custom Fields). Then it’s just comparing if the values match and there you go.

    Of course, if you have more than one element on your array, you need to loop through it. It’s horribly arbitrary way of getting it done, but works if really need be.

    Here’s my working bit. $rel_album might or might not be an array, and needs to be matched with $album_id:

    ...
    $song = new WP_Query( $song_args );
    while ( $song->have_posts() ) : $song->the_post();
    $rel_album = get_post_meta($post->ID, "related_album", true);
    if(is_array($rel_album)) :
    $rel_album = reset($rel_album);
    endif;
    if($album_id == $rel_album) :
    get_template_part( 'content', 'video' );
    endif;
    endwhile;
Viewing 1 replies (of 1 total)