• Resolved SidianMSJones

    (@sidianmsjones)


    I’m trying an alternative to my other support post. This time, for my custom post type “Meanings” I have created a relationship field regarding users, where users can assign Myth Keepers (basically authors) to each post.

    I would like to display the Myth Keepers and am attempting to do so with this code:

    [pods name="meaning" field="myth_keepers" limit="5"]

    Not sure why it isn’t working. Thank you for any help!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Paul Clark

    (@pdclark)

    This worked for me in testing:
    [pods name="meaning" slug="blue"][each myth_keepers]{@display_name} [/each][/pods]

    Plugin Support Paul Clark

    (@pdclark)

    Also this worked as PHP to add a shortcode, [myth_keepers]:

    <?php
    add_shortcode(
    	'myth_keepers',
    	function ( $a ) {
    		ob_start();
    
    		$meaning_pod = pods( 'meaning', get_the_ID() );
    
    		echo '<h3>Myth Keepers:</h3>';
    		foreach( $meaning_pod->field('myth_keepers') as $keeper ) {
    			echo $keeper['display_name'] . '<br/>';
    		}
    		
    		return ob_get_clean();
    	}
    );
    Thread Starter SidianMSJones

    (@sidianmsjones)

    Hey that’s great Paul, thanks! I couldn’t get your first solution to work for me because I’d have to put it on every Meaning page. I tried replacing the slug with things like “permalink” or “esc_url” but couldn’t get them to work.

    However the second solution works perfect.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @sidianmsjones

    Thanks for letting us know! Closing topic.

    Cheers, Jory

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trying to display relationship field’ is closed to new replies.