Get The Title and Permalink of a post From Relationship Field
-
Hi,
I am struggling for hours through the documentation trying to implement something that should be very simple, but to a non technical person like me its like a monster!
I have two pods as custom post types:
1) Books
2) AuthorsIn the books post type i have a relationship custom field related to the authors custom post type.
In the authors custom post type i have a relationship custom field related to the books custom post type.
Both as bi-derectional.
I already know hot to display the other custom fields, what i dont know is how to get the title and the permalink of the author of each book into each books custom post type and the list of the books assigned to each author into each authors custom post type.
For instance:
<?php add_action( 'genesis_before_entry_content', 'do_book_fields' ); function do_book_fields() { //get Pods object for current post $books = pods( 'books', get_the_id() ); $book_image = $books->display( 'book_image' ); //*adds the book image if its setted if ($book_image) {?> <dl><dt >Image:</dt> <dd><a itemprop="url" href="<?php echo get_permalink( $post->ID ); //*adds the url of the book?>" title="Book: <?php the_title(); ?> writen by <?php HOW TO GET THE TITLE AND URL OF THE AUTHOR HERE ?>"><img itemprop="image" src="<?php echo $ibook_image ?>" alt="Book <?php the_title(); ?>" title="<?php the_title(); ?>"/></a></dd></dl> <?php }}
I need a way to get the authors pages titles and urls to use inside the books pages and vice versa, and i would love if i could do it in a similar fashion as the other filds…
I tried to follow this tutorial: https://pods.io/tutorials/get-values-from-a-custom-relationship-field/ several times with no success at all.
Could someone please help me out on this?
Regards.
- The topic ‘Get The Title and Permalink of a post From Relationship Field’ is closed to new replies.