Php strpos function

Hi there, Im new to this. I have the following code but want to turn it into an ‘if’ statement using strpos function. Currently it excludes the Newsletter page. I would like the straps function to exclude any page that contains the word Newsletter - like NewsletterJan or NewsletterFeb etc etc

Current Code:
if( $maintenance == ‘disable’ || is_user_logged_in() || $pagenow == ‘wp-login.php’ || is_admin() || $query->query[‘pagename’]== ‘newsletter’) return;

Thanks

Richard

Well, you did not show your strpos code… So, not sure what your heading means compared to the code you showed.

But, this is how you use strpos…

You can find any string inside another with strpos. I am guessing that you want to add this to the $maintenance IF query, you can only do that if there is a string to check if the string exists in. Then, you would use something like if (!strpost($STRINGNAME, “Newsletter”)) then whatever. This will check if the string ($STRINGNAME) does NOT include the the string “Newsletter”, but, of course will not check if the string contains the string “newsletter”. Therefore, you might need to include that option as well.

Now sure it that is what you are requesting, but, hope it helps…

Maybe something like this is what you are looking for?

$nwsltrCheck = strpos(strtolower ($query->query[‘pagename’]), 'newsletter');  

if( $maintenance == ‘disable’ || is_user_logged_in() || $pagenow == ‘wp-login.php’ || is_admin() || is_numeric($nwsltrCheck)){
    return;
}
Sponsor our Newsletter | Privacy Policy | Terms of Service