0

I'm looking for a way to redirect to a specific wordpress page without knowing the ID.

I have a shortcode that is meant to redirect to a registration page once a button is clicked.

Before, I was able to just use a page ID. Now I am using WPML and the page ID's are all different for each language.

How can I redirect to a specific wordpress page without knowing the specific page ID for the current language?

Lee Loftiss
  • 3,035
  • 7
  • 45
  • 73
  • create a proxypage, locate the corresponding page id and make another redirect? – Soundz Aug 31 '13 at 03:27
  • Wouldn't the second redirect have the same problem of not knowing which ID to use based on the language? If not, then could you post an answer with a psuedo example? – Lee Loftiss Aug 31 '13 at 03:28

2 Answers2

0

Maybe you could use get_page_by_path() or get_page_by_title().

Both functions accept Post Type as argument, it's not only restricted to "pages". And they will return a full $post object, ie, $post->ID.

Maybe a WPML function is needed, an equivalent of those. Or maybe a combination.
See the docs for Language dependent IDs.

brasofilo
  • 25,496
  • 15
  • 91
  • 179
  • Thanks. I took a look at those. I think the issue is the same. With WPML, the page ID and title can both be different for each language. – Lee Loftiss Aug 31 '13 at 03:42
  • 1
    You might find this helpful: http://www.wpmayor.com/step-by-step/build-multilingual-site-wpml/ see the third subhead. – probablyup Aug 31 '13 at 03:58
0

You could add a custom field which will be shared by all versions of the same article, and then query by that instead. Something like an article GUID.

probablyup
  • 7,636
  • 1
  • 27
  • 40
  • WOW That's a pretty far-out idea. Unfortunately, it is not even approachable here. Interesting how Wordpress has never made it easier to access pages. – Lee Loftiss Aug 31 '13 at 03:53