Thread Starter
neha
(@glassfairy)
instead of custom field how can get the post’s permalink to be displayed for the selected store title…i have tried everything nothing seemss to work
Well, get_terms( ‘genre’ ) doesn’t work because ‘genre’ is a custom field and not a taxonomy or CPT-onomy.
As for the permalink, you have to get the selected store’s ID using wp_get_object_terms() and then use get_permalink():
// $post_id is the post ID of the current book
// I don't know the context of your code so you may
// have to replace this with your own info.
$stores = wp_get_object_terms( $post_id, 'actors' );
// $stores will contain arrays of info for each store
// that is assigned to the book, including the store's
// term_id which is the same as the store's post ID.
if ( $stores && !is_wp_error( $stores ) ) {
echo '<ul>';
foreach ( $stores as $store ) {
echo '<li><a href="' . get_permalink( $store->term_id ) . '">' . $store->name . '</a></li>';
}
echo '</ul>';
}
I hope this helps!
Thread Starter
neha
(@glassfairy)
is there any way to get the custom field in the posttype to be echoed after its converted to cpt-onomy?
p.s-thanx so much replying 🙂
Thread Starter
neha
(@glassfairy)
racehl with the code u gave …it pulls in the permalink of the current as well as the previous post from the CPT…is it pulling 2 of them
Thread Starter
neha
(@glassfairy)
also it pulla in the permalink of the post and not the cpt