Can a conditional statement apply to part of a slug?

WordPress has no conditional for substring testing but you can do this using PHPs built-in function: strpos()

global $post;

if( false !== strpos( $post->post_name, 'beef' ) ) {
    // Do Things
}

The above returns true if beef is found somewhere in the post slug.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)