Open JoaoFreitas2002 opened 6 months ago
I am using Polylang plugin and no matter the language, always return the same page.
I don't know how the other multi-language plugin work, but for polylang you can change the function to this:
public function custom_404_pro_redirect() { global $wpdb; if (is_404()) { $sql = 'SELECT * FROM ' . $wpdb->prefix . $this->helpers->table_options; $sql_result = $wpdb->get_results($sql); $row_mode = $sql_result[0]; $row_mode_page = $sql_result[1]; $row_mode_url = $sql_result[2]; $row_send_email = $sql_result[3]; $row_logging_enabled = $sql_result[4]; $row_redirect_error_code = $sql_result[5]; if ($row_logging_enabled->value) { self::custom_404_pro_log($row_send_email->value); } if ($row_mode->value === "page") { $page = get_post($row_mode_page->value); //Polylang if (function_exists("pll_get_post")) { $translated_page_id = pll_get_post($row_mode_page->value, pll_current_language()); $page = get_post($translated_page_id); } wp_redirect($page->guid, $row_redirect_error_code->value); } elseif ($row_mode->value === 'url') { wp_redirect($row_mode_url->value, $row_redirect_error_code->value); } } }
@JoaoFreitas2002 - thanks for this! I'll take a look and see what can be done.
I am using Polylang plugin and no matter the language, always return the same page.
I don't know how the other multi-language plugin work, but for polylang you can change the function to this: