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:// align center buttons with float. background transparency cache cache image with javascript Center align with float:left create own plugin custom admin menu default css for browsers disable admin menu disable backspace with javascript ezoe eZ publish eZ Publish Enterprise google API high performance gallery image cache InnoDB recover Javascript Images streaming Linux password recover Mongodb multiple wordpress sites permalinks on lighttpd photo gallery software php to get page content in wordpress preg_match youtube video id recover innodb from .ibd refresh image with javascript remove admin menu repair innodb tables reset linux debian password reset linux pass several sites in one wordpress admin strem images from IP camera translated page post category id visitors counter Wordpress wordpress network wordpress permalinks wordpress protect from hacks wordpress protect with .htaccess Wordpress user roles wpml get post id WPML translated 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.