WordPress.org

Ready to get started?Download WordPress

Forums

Pods - Custom Content Types and Fields
[resolved] Relationships: Linking Pages from two pods (3 posts)

  1. James Adamthwaite
    Member
    Posted 1 year ago #

    Before I write a novel about how I'm doing it and what's gong wrong, here's what I'm trying to do:

    Training courses.
    pod: courses
    pod: registration

    the courses pod list out the courses along with taxonomy and meta. the registration pods are iframe pages to a 3rd party registration system.

    So, I want to have a link on the course page to the associated reigistration page. I've got the relationship setup, and the fancy dropdown appears on my course page and I've selected the correct registration page.

    Now, to utilize this in a template field, I see that when I call that key, it's the numerical value of the pageID for the registration pod page. My attempts at producing an anchor link are failing in "Array" -- and digginig in I swear it's a single value... Can't I just get the direct URL for that registration pod page itself?

    My code:
    <a href="index.php?page_id=<?php echo get_post_meta($post->ID, registration, true); ?>">Register</a>

    Producing: /?page_id=Array

    Thanks in advance! (ps: i've looked all over for basic documentation on linking the two pages - or relationships in general)

    http://wordpress.org/extend/plugins/pods/

  2. James Adamthwaite
    Member
    Posted 1 year ago #

  3. Scott Kingsley Clark
    Member
    Plugin Author

    Posted 12 months ago #

    If you're trying to get the registration ID by using:

    <?php echo get_post_meta( $post->ID, 'registration.ID', true ); ?>

    In Pods, relationship fields are returned as arrays of their related data. In Pods 2.3.3 you can now change that to be any of the following:

    • arrays (default)
    • objects
    • ids
    • names

    To change the output type that Pods uses, you can utilize this filter:

    add_filter( 'pods_field_related_output_type', 'change_default_pods_output_type' );
    function change_default_pods_output_type ( $type ) {
        return 'ids';
    }

    By adding that filter, your original code should begin to work. Otherwise, use the modified code I showed above.

    Pods 2.3.3 will be released today.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic