$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>How to parse any content which was added after the working out filter 'the_content'|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin10PV0评论

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="/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="/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="/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?

Post a comment

comment list (0)

  1. No comments so far