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

Question

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.

0
Prateek Asthana 1 month 0 Answers 6 views 0

Leave an answer