When WP_Query only returns 1 post, how do I automatically redirect to that post?
You can do this by checking the number of results returned by your query. Try this. <?php $rawfiltertag = get_post_meta( $post->ID, ‘_cmb_client_name’, true ); $filtertag = sanitize_title( $rawfiltertag ); // wp_query arguments $args = array ( ‘post_type’ => ‘post’, ‘meta_query’ => array( array( ‘key’ => ‘_cmb_client_target’, ‘value’ => $rawfiltertag ) ) ); // the query … Read more