Title: Getting related post permalink value
Last modified: May 14, 2023

---

# Getting related post permalink value

 *  Resolved [supadigital](https://wordpress.org/support/users/supadigital/)
 * (@supadigital)
 * [3 years ago](https://wordpress.org/support/topic/getting-related-post-permalink-value/)
 * Hi
 * I have a pod called fsp_products. I also have another pod called product_thank_you_pa.
 * The fsp_products post type has a relationship field linking to the product_thank_you_pa
   pod, and the related field is called fsp_product_thank_you_page_url.
 * fsp_product_thank_you_page_url returns the TITLE of the related product_thank_you_pa.
 * I need to get the permalink of the related post using the this TITLE field value.
 * I have tried various code snippets from the documentation site without success.
 * I would really love it so much if someone could assist with this. It seems the
   latest version of wordpress has changed some of the get functions and one is 
   supposed to use wp_query now, but I am not clued up here. IF someone is able 
   to provide a possible code snippet for the above, i would be massively appreciative.
 * Thanks so much.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Jory Hogeveen](https://wordpress.org/support/users/keraweb/)
 * (@keraweb)
 * [3 years ago](https://wordpress.org/support/topic/getting-related-post-permalink-value/#post-16745386)
 * Hi [@supadigital](https://wordpress.org/support/users/supadigital/)
 * A relationship is always related to the object itself, not a param/prop of this
   object.
   Assuming you are using magic tags in our templates you can use the permalink
   property: {@relationship_field.permalink}
 * More info: [https://docs.pods.io/displaying-pods/magic-tags/](https://docs.pods.io/displaying-pods/magic-tags/)
 * Cheers, Jory
 *  Thread Starter [supadigital](https://wordpress.org/support/users/supadigital/)
 * (@supadigital)
 * [3 years ago](https://wordpress.org/support/topic/getting-related-post-permalink-value/#post-16747553)
 * Hi [@keraweb](https://wordpress.org/support/users/keraweb/)
 * I am actually needing to use the relationship field within a javascript code 
   snippet and it seems magic tags don’t work in scripts?
   Basically, what I am trying
   to do is get the permalink of the related pod by inserting the title of the that
   pod into the code snippet.
 * So when setting up an fsp_product, there is a relationship field that returns
   the title of a related pod post (product_thank_you_pa). I then insert that title
   into javascript snippet in order to get the permalink of that post and attach
   it to a variable in javascript which i then use later in the snippet for a redirect.
 * I have tried various snippets (I’m not too knowledgeable in coding, but rather
   using chaptgpt for snippets) but nothing works thus far. Any assistance would
   be appreciated. If its out of support scope, i understand. Thanks.
 * Below is one example of a snippet i used, but this returned an error: **Uncaught
   ReferenceError: Pods is not defined**
 * `<script> `
 * `document.addEventListener("DOMContentLoaded", function() { `
 * `// Get the selected "product_thank_you_pa" title from the related field `
   `var
   selectedTitle = Pods.getField('fsp_product', 'fsp_product_thank_you_page_url').
   find('option:selected').text(); `
 * `// Find the corresponding "product_thank_you_pa" by title`
   `var productThankYouPa
   = Pods.data.product_thank_you_pa.find(function(item) { ``return item.title ==
   = selectedTitle; }); `
 * `// Set the "url" variable to the fsp_product_thank_you_page_url of the selected"
   product_thank_you_pa"`
   `var url = productThankYouPa.fsp_product_thank_you_page_url;`
 * `// Use the "url" variable as needed `
   `console.log(url); }); `
 * `</script>`
 *  Plugin Author [Jory Hogeveen](https://wordpress.org/support/users/keraweb/)
 * (@keraweb)
 * [2 years, 12 months ago](https://wordpress.org/support/topic/getting-related-post-permalink-value/#post-16809019)
 * Hi [@supadigital](https://wordpress.org/support/users/supadigital/)
 * Magic tags are PHP only and do not work in JS. Where did you get the snippet 
   from? It doesn’t really look like anything from the Pods codebase.
   There are 
   some methods available in PodsDFV (`window.PodsDFV.getField()` for example). 
   This is all considered advanced usage meant for dev’s. Using AI for snippits 
   is unlikely for solve this for you.
 * Cheers, Jory
 *  Thread Starter [supadigital](https://wordpress.org/support/users/supadigital/)
 * (@supadigital)
 * [2 years, 12 months ago](https://wordpress.org/support/topic/getting-related-post-permalink-value/#post-16809707)
 * [@keraweb](https://wordpress.org/support/users/keraweb/)
 * Thanks so much for the feedback. I managed to do a workaround on this and forgot
   to close this ticket, apologies. Thanks though for your assistance, very much
   appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Getting related post permalink value’ is closed to new replies.

 * ![](https://ps.w.org/pods/assets/icon.svg?rev=3286397)
 * [Pods - Custom Content Types and Fields](https://wordpress.org/plugins/pods/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pods/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pods/)
 * [Active Topics](https://wordpress.org/support/plugin/pods/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pods/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pods/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 4 replies
 * 2 participants
 * Last reply from: [supadigital](https://wordpress.org/support/users/supadigital/)
 * Last activity: [2 years, 12 months ago](https://wordpress.org/support/topic/getting-related-post-permalink-value/#post-16809707)
 * Status: resolved