0
votes

in index.php (entry file) I have a $context["home-page"] = home_url(); yet for some reason when I implement it as <a href="{{ home-page }}">hello.com</a>. When rendering, I get a "0" value in href attribute: hello.com

when I dump that context value, I get this erroneous reply:

\wp-content\themes\hello\vendor\twig\twig\lib\Twig\Extension\Debug.php:50:int 0

Keep in mind that all the other contexts Work fine, such as:

  • $context["parent_link"] = get_template_directory_uri();
  • $context["is_single"] = is_single();

Is this somethin familiar to any of you?

1
the variable is not assigned in that caseCalimero
@Calimero no... if the variable was not set, the variable would be null thus resulting in an empty stringDarkBee

1 Answers

1
votes

Please try it this way:

$context["home_page"]

Instead of

$context["home-page"]

In twig templates {{ home-page }} should be interpreted as a substraction of variable home with variable page.

Edit: And like @DarkBee suggested you would have to define the variables before you can use them. That is why you get the error when debugging the context object.