Support » Plugin: Advanced Custom Fields » Page/Post link displaying its TITLE

  • Hello, i’d like to use a “links” box next to my posts, but having the links displaying the name/title of the post, and linking to it obviously. For now i could only use to display the URL to the post, but not having the actual post TITLE displayed.

    Anyone know how to do this? What i’m using right now is

    <?php echo get_field( ‘links’, $post_object->ID ); ?>

    Thanks for your help!

Viewing 1 replies (of 1 total)
  • There really isn’t enough information in your original post to give a proper answer to your question, but I’ll give a “best guess” about what you are attempting to do:

    I think, you would like to have posts (or pages) that are related to the post/page that is presently being displayed, displayed in a box, say in a sidebar.

    Assuming these are posts/pages are on your site, why would you not use a Relationship field for this? Then you would basically use the code from the ACF website to build your links to the posts.

    *  Loop through post objects ( don't setup postdata )
    *  Using this method, the $post object is never changed so all functions need a second parameter of the post ID in question.
    $posts = get_field('relationship');
    if( $posts ): ?>
    	<?php foreach( $posts as $post_object): ?>
    	    	<a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID); ?></a>
    	<?php endforeach; ?>
    <?php endif;
Viewing 1 replies (of 1 total)
  • The topic ‘Page/Post link displaying its TITLE’ is closed to new replies.