ISSUE-5246: Adding if-condition to prevent invalid arguement being passe...

...d into foreach() in different themes.