Support

Account

Home Forums Front-end Issues Relationship field – slug only?

Solved

Relationship field – slug only?

  • I am using the Relationship field to show a list of links. Is it possible to get just the slug and not the full permalink? This was the code I used:

     <?php while(has_sub_field('event_details')): ?>                                            
          <h3><?php the_sub_field('event_name'); ?></h3>
          <?php $links = get_sub_field('session_links');
           if( $links ):  foreach( $links as $link ): ?>
    	   <a href="<?php echo get_permalink( $link->ID ); ?>"><?php echo get_the_title( $link->ID ); ?></a>
            <?php endforeach; endif; endwhile ?>

    I appreciate any direction. Thank you.

  • I solved it. I just needed to use this:

    echo( basename(get_permalink()) );
    
    

    instead of get_permalink().

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Relationship field – slug only?’ is closed to new replies.