WordPress filter hook

translate_object_id

Fired by 18 WordPress plugins, running on 331K+ sites between them.

How to use translate_object_id

It's a filter: your callback receives the value and 3 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'translate_object_id', function( $posts, $post_type, $arg3, $lang ) {
	// Change $posts here.
	return $posts;
}, 10, 4 );

Argument names come from Seraphinite Accelerator's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

18 plugins that fire translate_object_id

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. TI WooCommerce Wishlist icon TI WooCommerce Wishlist100,000+ installs apply_filters( 'translate_object_id', $post_data['product_variation'], 'product_variation', true, $original_product_language ) integrations/woocommerce-multilingual.php:75
  2. Customer Reviews for WooCommerce icon Customer Reviews for WooCommerce80,000+ installs apply_filters( 'translate_object_id', $item['product_id'], 'product', true, $wpml_current_language ) includes/emails/class-cr-email-func.php:89
  3. Germanized for WooCommerce icon Germanized for WooCommerce70,000+ installs apply_filters( 'translate_object_id', $this->original_variation_id, 'product_variation', true, $lang ) includes/compatibility/class-wc-gzd-compatibility-wpml.php:194
  4. Seraphinite Accelerator icon Seraphinite Accelerator50,000+ installs apply_filters( 'translate_object_id', $posts[ 0 ] -> ID, $post_type, true, $lang ) Cmn/Gen.php:5807
  5. Advanced Dynamic Pricing and Discount Rules for WooCommerce icon Advanced Dynamic Pricing and Discount Rules for WooCommerce20,000+ installs apply_filters( 'translate_object_id', $productId, 'post', false, $this->languageCode ) BaseVersion/Includes/Compatibility/Wpml/WpmlObjectInternationalization.php:27
  6. Loyalty Points Rewards and Referral for WooCommerce icon Loyalty Points Rewards and Referral for WooCommerce3,000+ installs apply_filters( 'translate_object_id', $prod_id, 'product', false, $current_lang ) App/Helpers/Woocommerce.php:1122
  7. WP Hotelier icon WP Hotelier2,000+ installs apply_filters( 'translate_object_id', $extra_id, 'extra', true ) includes/admin/meta-boxes/views/reservation/html-meta-box-reservation-single-item.php:127
  8. Carousel Horizontal Posts Content Slider icon Carousel Horizontal Posts Content Slider2,000+ installs apply_filters( 'translate_object_id', $id, get_post_type( $id ), true ) carousel-horizontal-posts-content-slider.php:1196
  9. OnSale Page for WooCommerce icon OnSale Page for WooCommerce2,000+ installs apply_filters( 'translate_object_id', $onsale_page, 'page', true, $language['language_code'] ) public/class-woocommerce-onsale-page-public.php:253
  10. Seraphinite Post .DOCX Source icon Seraphinite Post .DOCX Source800+ installs apply_filters( 'translate_object_id', $posts[ 0 ] -> ID, $post_type, true, $lang ) Cmn/Gen.php:5627
  11. DataFeedWatch Connector for WooCommerce icon DataFeedWatch Connector for WooCommerce600+ installs apply_filters( 'translate_object_id', $a2cData['meta_data']['parent'], $termType, false, $currentLangCode ) bridge2cart/bridge.php:2254
  12. CDI icon CDI200+ installs apply_filters( 'translate_object_id', $item['product_id'], 'product', false, $language_to_filter ) examples/CDI-filters-example.php:308
  13. Splash Sync icon Splash Sync100+ installs apply_filters( 'translate_object_id', $postId, 'post', true, $this->getDefaultLanguage() ) src/Services/MultiLang/WpmlProvider.php:84
  14. Api2Cart Bridge Connector icon Api2Cart Bridge Connector40+ installs apply_filters( 'translate_object_id', $a2cData['meta_data']['parent'], $termType, false, $currentLangCode ) bridge2cart/bridge.php:2254
  15. Seraphinite Alternative Slugs Manager icon Seraphinite Alternative Slugs Manager20+ installs apply_filters( 'translate_object_id', $posts[ 0 ] -> ID, $post_type, true, $lang ) Cmn/Gen.php:4715
  16. Seraphinite Bulk Discounts for WooCommerce icon Seraphinite Bulk Discounts for WooCommerce20+ installs apply_filters( 'translate_object_id', $posts[ 0 ] -> ID, $post_type, true, $lang ) Cmn/Gen.php:5023
  17. Seraphinite Downloads Statistics icon Seraphinite Downloads Statistics10+ installs apply_filters( 'translate_object_id', $posts[ 0 ] -> ID, $post_type, true, $lang ) Cmn/Gen.php:5462
  18. Crypto Coin Market Prices icon Crypto Coin Market Prices10+ installs apply_filters( 'translate_object_id', $post -> ID, $post -> post_type, true, $lang ) Cmn/Gen.php:1364

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.