How can I pass a variable from a template to header.php of a theme


As of version 5.5.0, WordPress introduced second argument (array $args) to get_header.

I am calling get_header in my templates including index.php and I want to pass meta description value from template to header.php

And I am trying this

$args = array('Index meta desc');
get_header(null, $args);

While in header.php file the value of $args is an empty array.

Not sure, if I am calling the variable correctly.

Any comment/answer will be helpful.
Thank you.

Prateek Asthana 8 months 2020-12-10T10:10:57-05:00 0 Answers 6 views 0

Leave an answer