ACF Related Links

I would like to display the title and link of a related post of another custom post type in a profile item created in ACF in the author box at the bottom of the post page.

I could not display the title and link of the related post of another custom post type by simply reflecting them in the “Dynamic text type” and “Dynamic link type”.

Hi Marumoro,

Related posts are quite complicated as they need an algorithm to find out what’s related vs. what’s not.

You would need custom code or a third party plugin to achieve this.

If you set a Headline’s dynamic text type to Post meta, and specify the meta field name you set in your acf, you would be able to retrieve it given that it’s a post meta of the current post.

See: Image 3-8-2022 at 1.43 PM

Otherwise, if it’s not a post meta of the post itself, as mentioned, you would need custom code or a third party plugin.

Hope this clarifies! :slight_smile:

Thank you.

If the Dynamic text type title is set to something other than Post title, the actual Post title will not be displayed.

We frequently see cases where the previous and next posts of the author are displayed on magazine websites, so there must be a certain number of users who need this feature.

Therefore, it would be very helpful if you could implement the “same author” function in the “In the same term” section.

That would be a nice function. :slight_smile: Alternatively, for now, we can also achieve this with a custom PHP code like:

add_filter( "get_next_post_where", function($where, $in_same_term, $excluded_terms, $taxonomy, $post){
  $where .= " AND p.post_author='".$post->post_author."'";
  return $where;
}, 10, 5);

add_filter( "get_previous_post_where", function($where, $in_same_term, $excluded_terms, $taxonomy, $post){
  $where .= " AND p.post_author='".$post->post_author."'";
  return $where;
}, 10, 5);

Tested this on my end and it seems to be working. You may use a plugin like Code Snippets to add PHP code.

Hope this helps! :slight_smile:

Thank you!

However, there are two points where it does not work.

First, the title of the next post is displayed correctly, but the link for does not work.
Second, the dates of the previous and next posts show the latest date.

I see. For further assistance with regards to this, may you kindly create a topic here?: Support - GeneratePress :slight_smile: