Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Singular template for Artist CPT
*
*
* @package Oblates
* @subpackage Template
*/
get_header(); // Loads the header.php template. ?>
<div class="content">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
<h1 class="entry-title artwork-title"><?php single_post_title(); ?></h1>
<div class="entry-content">
<?php $artworks = get_posts(array(
'post_type' => 'artworks',
'meta_query' => array(
array(
'key' => 'artist', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
?>
<?php if( $artworks ): ?>
<ul>
<?php foreach( $artworks as $artwork ): ?>
<li>
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $artwork->ID ), 'thumbnail' ); ?>
<img src="<?php echo $thumb[0] ?>" />
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div><!-- #content -->
<?php get_sidebar( 'artwork' ); // Loads the sidebar-prayers.php template. ?>
<?php get_template_part( 'loop-nav' ); // Loads the loop-nav.php template. ?>
<?php get_footer(); // Loads the footer.php template. ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.