WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] Get the ID of the Related Post inside a ShortCode (3 posts)

  1. raonip
    Member
    Posted 2 years ago #

    Hi,

    I'm trying to use this plugin to relate a Post to a Custom Post Type Called "Gallery".

    What I need is in my single-gallery.php I have to Get the ID of the Related Post inside my ShortCode.

    See below:

    <?php echo do_shortcode('[portfolio_slideshow id=here comes the post related ID]'); ?>

    Anyone could help me???

    Is there a way to do that!?

    Thanks Very Much!!!!!

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    $connected = get_posts( array(
      'connected_type' => 'YOUR_CONNECTION_TYPE_NAME',
      'connected_items' => get_queried_object_id(),
      'suppress_filters' => false
    ) );
    
    $connected_id = $connected[0]->ID;
    
    echo do_shortcode("[portfolio_slideshow id=$connected_id]");
  3. raonip
    Member
    Posted 2 years ago #

    Hi! Thanks very very much!!!!!!!!!!!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic