nerijuso.lt

nerijuso.lt

  • Home
  • About
  • Tools
    • Border Radius
    • My IP
    • Fahrenheit to Celsius
    • Inches to centimeters (cm)

Search


Kinsta hosting

Categories

  • eZ Publish/eZ Components
  • Html/CSS/JavaScript
  • My projects
  • Other
  • Wordpress

Blogroll

  • Domains
  • Eventizer
  • Hosting
  • Image optimisation tool
  • Images gallery
  • Instagram scheduler
  • Tattoo gallery
  • Universe gallery

TagCloud

100 top plugins add http:// background transparency cache cache image with javascript check image check jpg files combobox style css equal columns css for select box css same height columns decomplress image equal columns on bootstrap ezoe eZ publish get first paragrapth get vimeo video image how to style selectbox image cache InnoDB recover javascript cache Mongodb multiple wordpress sites nginx page 404 error paragraph php-fpm install php 5.4 on centos php remove empty p tags php to get page content in wordpress preg_match youtube video id recover innodb from .ibd scan jpg scan JPG files select box style selectbox style several sites in one wordpress admin tinymce add custom class vimeo.com video image Vimeo video parser whmcs addon for livehelper chat whmcs livehelper chat addon wordpress custom class in tinymce wordpress network wpml get post id

Tag: wpml get post id

WMPL get (post, page, category) dependent IDs

October 30, 2012 by nerijuso·0 Comments

1) Automatically Adjust IDs

WPML can hook to WordPress API functions, detect when specific items are loaded and adjust IDs so that the results are adjusted for the active language.

This functionality is enabled by default and can be accessed via WPML->Languages (visible in Advanced mode):

Auto-adjust IDs

This will automatically adjust all IDs and can be used in any WordPress theme that uses the API correctly (almost any theme you can find).

2) Manually, using the icl_object_id function

Alternatively, if the automatic ID adjustment is off, you can use the icl_object_id function to achieve the same manually.

icl_object_id(ID, type, return_original_if_missing,language_code)

  • ID – the ID of the post, page, tag or category
  • type – ‘post’, ‘page’, ‘post_tag’ or ‘category’
  • return_original_if_missing – true if WPML should return the ID of the original language element if the translation is missing or false if WPML should return a NULL if translation is missing.
  • language_code (optional) – if set, forces the language of the returned object and can be different than the displayed language.

The ID argument can be the ID of the object in any language. What the function will do is look up the translation group for that object and then the ID of the corresponding object in the active language.

Example usage

icl_object_id(3, 'category', false)

Return the ID of the category that is the translation of category 3. If it’s missing, return NULL.

Proudly powered by WordPress. Theme: Flat 1.7.11 by Themeisle.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok