Wordpress - 忽略外部分区的短代码

时间:2014-11-23 21:34:55

标签: html html5 wordpress-theming wordpress

我发现了一个问题,我真的不明白发生了什么。所以我有一个div,在那个div中有一个嵌套的短代码。

编辑:短代码正在输出,它只是忽略它嵌套的所有div并单独输出,强制它高于页面上其他内容。

例如:

<div id="adiv"> [SHORTCODE][/SHORTCODE] </div> <!-- Should output the same way, right? -->

而是输出:

    [SHORTCODE][/SHORTCODE]
    
    <div id="adiv"><div> <!-- Completely ignoring the fact that the shortcode is nested -->

我发誓我不是一个完整的菜鸟,但这可能是一个菜鸟问题。任何和所有的帮助都得到了认可。我很困惑,至少可以说!

谢谢, Jamsplash

1 个答案:

答案 0 :(得分:1)

我设法回答了我自己的问题,希望我可以帮助其他人解决同样的问题:

&#13;
&#13;
/*-------------------------------------------------------------------
 *						Some Shortcodey Thingy
 *------------------------------------------------------------------*/

add_shortcode('thingy','thingy_shortcodes');

function thingy_shortcodes( $atts, $content = null )
{
	extract(shortcode_atts(array( 'category' => '0'),$atts));
	
	ob_start(); <!--- use this to set the content you want to get AKA the stuff you                       want FOR DISPLAY -->
	
	STUFF FOR DISPLAY...... 
    GOES HERE

	$popular = ob_get_contents(); <!-- Set the variable that is going to dispay your                                        STUFF FOR DISPLAY-->
	ob_end_clean();               <!-- Where STUFF FOR DISPLAY ENDS-->

	return $popular;              <!-- Return your content -->
}
&#13;
&#13;
&#13;

相关问题