Hello @byron222,
Thank you for contacting the support.
Yes. You can use the Redirection\DB:add
function to add the new redirections from the functions.php file:
Code:
\RankMath\Redirections\DB::add(
[
'url_to' => $redirection['url_to'],
'sources' => $sources,
'header_code' => $redirection['header_code'],
'hits' => $redirection['hits'],
'created' => $redirection['created'],
'updated' => $redirection['updated'],
]
);
Reference code:
https://github.com/rankmath/seo-by-rank-math/blob/master/includes/admin/class-import-export.php#L464-L485
This code is from the Import file which we use to import the Redirection rules from other plugins.
Hope that helps.