get variables data from functions.php to template wordpress (without global variables)

Question

I have in wordpress functions.php file

This sample works with one variable only, but i want multiple variables

function variables() {
   $var1 = 'lorem';
    return $var1;
}

in the front template results “lorem”:

echo variables();

works fine, but if i have many variables how can i displayed it?

example:

echo variables('var1');
echo variables('var2');
echo variables('etc');

i found a solution using global variables, but i don’t like use that.

edit:

in functions.php add variables :

$some = "lorem 1"
$some2 = "lorem 2"
$some3 = "lorem 3"

then display in theme

<?php echo some(); ?>
<?php echo some2(); ?>
<?php echo some3(); ?>
0
, Chris 1 year 2020-07-11T22:11:23-05:00 0 Answers 68 views 0

Leave an answer

Browse
Browse