Hi,
You could do:
is_page() && strpos( $GLOBALS['post']->post_name, 'Helsinki' ) !== false
The strpos
checks if the substring (Helsinki
) exists anywhere within the original string (here: the post slug). Of course, you could use preg_match
and do super complex pattern detection with Regex as well.
You are me HERO! Thanks a lot.
Knowing that I have only pages (no posts/articles) I omitted “is_page()”.
Hope that is no problem – seems that works.
Glad to be of help.
It might be a good idea to put that in; in archive pages the $post
variable refers to the first post in the list, so there’s a chance you might end up showing the menu in unwanted places. Also it may be $post
is not set at all (say maybe in custom pages added by plugins, etc.) and $GLOBALS['post']->post_name
would generate an error, whereas the is_page()
check would prevent that. To ensure there’s no error you could add a isset( $GLOBALS['post'] )
instead.