所见即所得html DIV之外抛出的WordPress简码

Jon*_*org 0 html wordpress static-html shortcode

我正在尝试通过Wordpress页面所见即所得(WYSIWYG)编辑器在特定<div>元素中在页面中放入一个简码。短代码确实会出现并起作用。但是<div>,当页面呈现时,它不会停留在my内,而不会呈现在<div>页面的顶部附近,而是引导页面内容。

关于如何防止这种情况有什么想法?

我不想将其放在页面模板内。我试图将其放置在Pages WYSIWYG编辑器内布置的简单自定义html中。

例如,我在页面中放置简码,如下所示:

<div class="row">
<p>some custom page html content</p>
<div>
<div class="row">
[some_shortcode]
</div>
<div class="row">
<p>some custom page html content</p>
<div>
<div class="row">
<p>some custom page html content</p>
<div>
Run Code Online (Sandbox Code Playgroud)

而是这样渲染:

<!-- THE SHORTCODES HTML APPEARS HERE and Works but not where I wanted it. -->
<!-- then the rest of the pages html content -->
<div class="row">
<p>some custom page html content</p>
<div>
<div class="row"><!-- no more shortcode-->
</div>
<div class="row">
<p>some custom page html content</p>
<div>
<div class="row">
<p>some custom page html content</p>
<div>
Run Code Online (Sandbox Code Playgroud)

doj*_*ojs 5

每当插件打印出其内容而不使用return时,就会发生此问题。

有关更多信息,请参见Shortcode API文档。 http://codex.wordpress.org/Shortcode_API#Output

  • 好的,在您的插件中,您是否正在回显/打印内容?如果是,则需要使用return。 (2认同)