Support

Account

Home Forums General Issues Display the Text Label from a Page Link

Solved

Display the Text Label from a Page Link

  • http://elmwoodplayhouse.com/volunteer/arthur-chill/

    I have the two fields I am trying to show as well
    The “Season” (which is a Page link field inside of the custom post type ‘show” which links to a specific custom post under “seasons”) which is return the URL which is exactly whats its supposed to do. But I would like it to display its Posts Title instead of what I what know instead of “SEASON” I had figured a page link was the best approach for this. Was this not correct? Should I have make that field a Post Object instead?

    I am using the the_sub_field(‘show_role’); command to display the text field that pertains to the related records figuring it would be straight forward but it does not seem to be displaying.

    <?php
     //Get the volunteer posts ID
     $post_id = get_the_ID();
    
    //Fetching all shows the volunteer was actor in
     $args = array(
     'numberposts' => -1,
     'post_type' => 'show',
     'meta_key' => 'opening_night',
     'orderby' => 'meta_value_num',
     'order' => 'DESC',
     'meta_query' => array(
     array(
     'key' => 'cast_%_actor',
     'compare' => '=',
     'value' => $post_id,
     )
     )
     );
    
    $show_actor_query = new WP_Query($args);
    
    ?>
    
    <?php if( $show_actor_query->have_posts() ): ?>
    
    <h3 style="margin-top:15px;">As A Cast Member:</h3>
     <ul class="biocredits">
     <?php while( $show_actor_query->have_posts() ): $show_actor_query->the_post(); ?>
    
        "><?php the_title(); ?> (">SEASON) <?php the_sub_field('show_role'); ?>
    
    <?php endwhile; wp_reset_postdata(); ?>
    
    <?php endif; ?>
  • Any update on this”?

  • Your code and your explanation are a bit confusing. You’re using the_sub_field(), but there is no repeater loop. Are these fields part of a repeater? You’ll need to look at this http://www.advancedcustomfields.com/resources/the_sub_field/, there is an example of a repeater loop there.

    It you want to show the title of a page that goes along with a page link field, this can be done by getting the field without formatting it. This should return the post ID and then you’ll need to get the permalink for the page and the title yourself. for more information on this see http://www.advancedcustomfields.com/resources/get_field/

    
    $page_link_id = get_field('page_link_field', false, false);
    echo get_the_title($page_link_id),'<br />',
           get_permalink($page_link_id);
    
  • Okay I’ll review the link you suggested and see what I can fine. Thanks Ill let you know.

  • Yes that was it! Now I just have to figure out how to get the other subfield in there. But thanks for the point in the right directioN!

  • This reply has been marked as private.
  • Just following up on this as I havent heard a response yet? Thanks!

  • You need to create a loop to show the sub fields of the repeater where you have SHOWROLE GOES HERE and CREW POSISTION GOES HERE

    See this page for an example of a loop for a repeater http://www.advancedcustomfields.com/resources/have_rows/

  • okay Thanks. I didn’t realize I would need a second loop. I will proceed in that matter. Thanks for pointing me in the right direction

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

The topic ‘Display the Text Label from a Page Link’ is closed to new replies.