i wanna get the index of current post fetched in a preg_match to be used

 if (preg_match('/allowfullscreen/',$content)){

    echo "<script>


I want to add a class just for the current post not all posts in each post content that contains the word "allowfullscreen" so i need something like this :


PS : $content = get_the_content()

  • If you're on a category page, by definition there is no current post, or rather, every post is the current post at the moment you output it. You'll have to be a lot more specific and descriptive if you mean something else – Tom J Nowell Oct 19 '17 at 23:22
  • yes, that's what i mean .. i just want to add a class for the current post that its content contains "allowfullscreen" .. – No signal Oct 19 '17 at 23:40
  • preg_match uses regex for that, it seems overcomplicated, have you considered testing with strpos? Or better yet, just add a checkbox in the backend and store it in post meta – Tom J Nowell Oct 20 '17 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.