-
Hi,
I’m trying to make a custom variable to return current financial year for SEO Title and Meta Description, below is my code
function FinancialYear(){ $year = date('Y'); $cyear = substr($year, -2) + 1; return $year.'-'.$cyear; } add_action( 'rank_math/vars/register_extra_replacements', function() { RankMathHelper::register_var_replacement( 'fy',array('FinancialYear'),$args = array( 'name' => esc_html__( 'Financial Year', 'rank-math' ), 'desc' => esc_html__( 'Return the current Financial year', 'rank-math' ), 'example' => esc_html__( '2020-21', 'rank-math' ))); });
However, the problem is that, it works perfectly fine within the Admin, i.e. shows the financial year in the preview, but returns nothing in the frontend.
Please help me fix this…
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The ticket ‘Custom Variable Not Working in Frontend’ is closed to new replies.