preg_match_all doesnt't work with content
-
Hello everyone,
I am creating a very simple WordPress page (5 pages).
The template is pretty simple but every single page have a different combination of boxes and information.That’s why I decided to prepare 5 pages (without any posts).
By default every page/post have Title and Body(content) Field.To make it simpler I am trying to write the Body in this way:
[TOP PART]This is subtitle[/TOP PART] [BOX]This is my box 1[/BOX] [BOX]This is my box 2[/BOX].
in my index.php I am trying to filter it with preg_match_all:
$string = apply_filters( 'the_content', get_post_field( 'post_content', get_option( 'page_for_posts' ) ) ); $preg = preg_match_all('/\[BOX\](?:(.+?)?\[\/BOX\])/', $string , $matches); var_dump($matches);
Unfortunately I received an empty Array. If I display the $string I see the content with this boxes.
Any idea why preg_match_all() doesn’t work with content of the post/page?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘preg_match_all doesnt't work with content’ is closed to new replies.