pll_pre_translation_url

Filter the translation url before Polylang attempts to find one Internally used by Polylang for the static front page and posts page.

Description

apply_filters( 'pll_pre_translation_url', (string) $var, (object) $language, (int) $queried_object_id ); 

Parameters (3)

0. $var (string) => ''
Empty or the url of the translation of teh current page
1. $language (object)
Language of the translation
2. $queried_object_id (int)
The queried object id.

Usage

To run the hook, copy the example below.
  1. $var = apply_filters( 'pll_pre_translation_url', $var, $language, $queried_object_id ); 
  2.  
  3. if ( !empty( $var ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the pll_pre_translation_url callback 
  2. function filter_pll_pre_translation_url( $var, $language, $queried_object_id ) { 
  3. // make filter magic happen here... 
  4. return $var
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'pll_pre_translation_url', 'filter_pll_pre_translation_url', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'pll_pre_translation_url', 'filter_pll_pre_translation_url', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

/frontend/frontend-links.php  
  1. if ( ! $url = apply_filters( 'pll_pre_translation_url', '', $language, $queried_object_id ) ) {