Polylang and add_rewrite_rule
-
Hello.
I am trying to add polylang pll_get_post to work with a custom plugin I’ve created. My issue is the code belowfunction custom_rewrite_basic() { add_rewrite_rule('^el/transfer-from-([^/.]+)-to-([^/.]+)', 'index.php?page_id='.pll_get_post(get_option('we_taxi_search_results_id')).'&from=$matches[1]&to=$matches[2]', 'top'); //echo 'index.php?page_id='.pll_get_post(get_option('we_taxi_search_results_id')).'&from=$matches[1]&to=$matches[2]'; add_rewrite_rule('^transfer-from-([^/.]+)-to-([^/.]+)', 'index.php?page_id='.pll_get_post(get_option('we_taxi_search_results_id')).'&from=$matches[1]&to=$matches[2]', 'top'); } add_action('init', 'custom_rewrite_basic');
If I echo the pll_get_post etc, it shows me the correct ID.
When I try to access that page rewrite, it loads the frontpage. I’ve checked the debug toolbar and i see that the ID is not passed on the rewrite table. It goes like page_id=&from=$matches[1]
If I remove the pll_get_post, I get the ID and everything working as should.
Is there any way to tell wordpress to run this part after Polylang is initialized? It seems that the init cannot use polylang’s pll_get_post function
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Polylang and add_rewrite_rule’ is closed to new replies.