dongshi7433 2019-01-31 11:49
浏览 38

如何解析在计算过滤器'the_content'之后添加的任何内容

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 -->

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>

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 -->

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大