I am trying to add some logic to a wordpress template.
I want to build a simple if conditional which will check if a variable equals 26.
The variable “$value” must contain some extra hidden characters, because when I echo the content… 26 appears before the echo string values that should appear first.
Therefore, the if-condition does not work either.
What is happening here and how can i fix it?
CODE:
$value=the_ID(); // a wordpress function which contains the id of the current page/post.
echo "value=(" . $value . ")";
OUTPUT:
26value=()
This is because the_ID() is a template function: it only echo’s out the ID; it doesn’t return it. You want to be using get_the_ID() instead.