Closed anmamtl closed 7 years ago
<?php
$args = array(
'orderby' => 'title',
'post_type' => 'catalogs'
);
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
$attached = get_post_meta( get_the_ID(), 'attached_artworks_in_catalog', true );
foreach ( $attached as $attached_post ) {
$price = get_post_meta( $attached_post, 'price', true );
$artist = get_post_meta($attached_post, '_byd_artist_name', true );
?>
<div>
<a href="<?php echo get_permalink($attached_post) ?>">
<?php echo get_the_post_thumbnail($attached_post, 'catalog-thumb'); ?>
<?php echo get_the_title ($attached_post) ?> </a>
<?php echo $price ?>
<?php echo $artist; ?>
</div>
<?php }
?>
<?php endwhile; else: ?> <p>Sorry, there are no posts to display</p> <?php endif; ?>
<?php wp_reset_query(); ?>
Got it, I just had to retrieve the title :
<?php echo get_the_title ($artist); ?>
Closing.
Hello :)
Im using Attached posts with Field Ajax Search in Wordpress: https://github.com/rubengc/cmb2-field-ajax-search
I have a custom post type named Artworks, filled with Artworks entries.
I have a custom post type named Artists, filled with artists names that are linked with artworks.
I have a custom post type name Catalog, where selected artworks are attached to single catalogs using Attached Posts.
In each Artworks entries, I have a field using Field Ajax Search that retrieves these artist and assigns an artist to this the artwork.
In the catalog single page, Im trying to retrieve all artworks linked with this catalog.
From here, all is working. However, when trying to retrieve the artist name, it returns the ID instead of the name. How can I retrieve the name?
Thank you very much!