Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get the contents of the custom field 'post-band-name', create variable $thebandname
- <?php $thebandname = get_field('post-band-name'); ?>
- // Display only if the custom field 'post-band-name' has something in it (a value)
- <?php if( get_field('post-band-name') ): ?>
- // Query only the post we specified
- <?php $the_query = new WP_Query( array(
- 'post_type' => 'band', // The name of the Custom Post Type. (This is needed if you want to retrieve ACF fields.)
- 'name' => $thebandname // Retrieve the variable which has our post name
- ) ); ?>
- // While there are posts to show, show the post
- <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
- // ----- INSERT POST CONTENT HERE! -----
- <div class="artistinfoblock">
- <h2 class="artist-name"><a href="<?php the_permalink(); ?>"><?php the_field('artist-name'); ?></a></h2>
- <h3 class="artist-location"><?php the_field('artist-location'); ?></h3>
- </div>
- <?php endwhile; ?>
- <?php wp_reset_postdata(); ?> // Important because we are using a loop within a loop.
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement