0

I have a CPT called Movies and Episode List. I create a movie called "Paranormal Activity" and I create "episode 1", "episode 2", "episode 3", "episode 4". I connect each of them to "Paranormal Activity" with plugin post 2 posts by scribu. I have follow the tutorials here posts 2 posts support forum its still don't work.

enter image description here

It's shown at http://localhost/movie/conor ( what I called "Paranormal Activity") and this is the code what I have tested:

$episode_id = get_the_ID();

$prev = p2p_type( 'posts_to_pages' )->get_adjacent_items( $episode_id );

$next = p2p_type( 'posts_to_pages' )->get_adjacent_items( $movie_id, $episode_id );

$items = p2p_type( 'posts_to_pages' )->get_adjacent_items( $episode_id );

echo get_permalink( $items['parent'] );

if ( $items['previous'] )
 echo 'previous: ' . get_permalink( $items['previous'] );

if ( $items['next'] )
 echo 'next: ' . get_permalink( $items['next'] );
0

1 Answer 1

0

this works.

$connection_type = 'posts_to_pages';
$items = p2p_type($connection_type)->get_adjacent_items( $episode_id );

if ( $items['previous'] )
  echo get_permalink($items['previous']->ID);
1
  • Please don´t just post code, explain what it does and why it works.
    – flomei
    Feb 26, 2016 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.