returning the currect URL for nested posts

I have a posttype called (article) witch have a meta_key called (parents_ids).

So the article can be related to multiple articles.

I want to return the currect URL depending on the parent post

For example:

1-If the user click on the child-article comming from parent-article-1 i want the url to be example.com/parent-article-1/child-article.

2-If the user click on the child-article comming from parent-article-2 i want to return the url example.com/parent-article-2/child-article

Topic url-rewriting urls query-posts custom-post-types Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.