Get specific div from a wordpress page

On my admin panel I have a page called “Les Vétérans”.
In this page I wrote some content into a custom div called “description” on the WYSIWYG.

Now in my php code, I want to display this div without using the_content();
I just want to target and display only this div and not the rest (there is more content on this page).

Related posts

Leave a Reply

1 comment

  1. You need to get the content and then with a regular expression get tge part that you want.

    Here is example code:

    $content = get_the_content();
    
    if (preg_match('/<div id="mydiv">([^<]*)</div>/', $content, $matches) ) {
        echo $matches[1]; //This is my div
    }