0

How to parse any content which was added after the working out filter 'the_content'?

For example I have html structure of the simple page that i was created via Worpdress Admin Dashboard -> Pages -> Add New Page:

<div id="content" class="site-content">
    <div class="wrap">
        <div id="primary" class="content-area">
            <main id="main" class="site-main" role="main">
                <article id="post-20" class="post-20 page type-page status-publish hentry">
                    <header class="entry-header">
                        <h1 class="entry-title">Some page</h1>
                        <span class="edit-link">
                            <a class="post-edit-link" href="http://wp.loc/wp-admin/post.php?post=20&amp;action=edit">Edit
                                <span class="screen-reader-text"> "Some page"</span>
                            </a>
                        </span> 
                    </header><!-- .entry-header -->
                    <div class="entry-content">
                    </div><!-- .entry-content -->
                </article><!-- #post-## -->

            </main><!-- #main -->
        </div><!-- #primary -->
    </div><!-- .wrap -->
</div>

After that with some code i add anything to the page.php of my theme. For example:

    <ul>
        <li>Some content after working out "the_content" filter</li>
        <li>Some text</li>
        <li>Some text</li>
        <li>Some text</li>
        <li>Some text</li>
    </ul>

After that i get this page:

<div id="content" class="site-content">
    <div class="wrap">
        <div id="primary" class="content-area">
            <main id="main" class="site-main" role="main">
                <article id="post-20" class="post-20 page type-page status-publish hentry">
                    <header class="entry-header">
                        <h1 class="entry-title">Some page</h1>
                        <span class="edit-link">
                            <a class="post-edit-link" href="http://wp.loc/wp-admin/post.php?post=20&amp;action=edit">Edit
                                <span class="screen-reader-text"> "Some page"</span>
                            </a>
                        </span>
                    </header><!-- .entry-header -->
                    <div class="entry-content">
                    </div><!-- .entry-content -->
                </article><!-- #post-## -->

            </main><!-- #main -->
        </div><!-- #primary -->
    </div><!-- .wrap -->

    <ul>
        <li>Some content after working out "the_content" filter</li>
        <li>Some text</li>
        <li>Some text</li>
        <li>Some text</li>
        <li>Some text</li>
    </ul>
</div>

So, when i call filter 'the_content' i get just this:

<div id="content" class="site-content">
<div class="wrap">
    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">
            <article id="post-20" class="post-20 page type-page status-publish hentry">
                <header class="entry-header">
                    <h1 class="entry-title">Some page</h1>
                    <span class="edit-link">
                        <a class="post-edit-link" href="http://wp.loc/wp-admin/post.php?post=20&amp;action=edit">Edit
                            <span class="screen-reader-text"> "Some page"</span>
                        </a>
                    </span> 
                </header><!-- .entry-header -->
                <div class="entry-content">
                </div><!-- .entry-content -->
            </article><!-- #post-## -->

        </main><!-- #main -->
    </div><!-- #primary -->
</div><!-- .wrap -->

I need to concatenate $content and the content that was added after working out "the_content" filter. I think that i need to use Dom Parser for this. Any suggestions?

  • Are you putting all that HTML into the page editor? That's really not how WordPress is supposed to be used. That sort of markup belongs in a template. – Jacob Peattie Jan 31 at 10:19
  • @Jacob Peattie No, I dont put HTML code into the page editor. This HTML code is just a copy of HTML structure of the page which i create. – Finezxc Jan 31 at 10:27

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.