Support

Account

Home Forums Front-end Issues Page Link Value

Helping

Page Link Value

  • My question is regarding using the_field with Page Links. When I use:

    <?php the_field('page_link'); ?> or <?php echo get_field('page_link'); ?>

    The value returned can be used like this: <a href="<?php the_field('page_link'); ?>">Read this!</a>

    However, what want to return is the page name of the post being linked. In other words what I want to do is:

    <a href="<?php the_field('page_link'); ?>"><?php SOME OTHER CODE ?>!</a>

    Where the second function returns the name of the page being linked to rather than just the url.

  • Use the post object field instead!

    It’ll give you the entire post object (duh) instead of just a link.

    
    <?php $postobject = get_field('post_object'); ?>
    <a href="<?php echo get_permalink($postobject->ID); ?>"><?php echo $postobject->post_title; ?></a>
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Page Link Value’ is closed to new replies.