短代码:
[permalink][title][/permalink]
输出:<a href="foobar">[title]</a>
Wordpress短码API sais,正确无误:有什么想法吗?短代码:
[permalink][title][/permalink]
输出:<a href="foobar">[title]</a>
Wordpress短码API sais,正确无误:有什么想法吗?从链接的页面:
如果它们的处理函数通过递归调用do\\u shortcode()来支持嵌套的shortcode宏,则shortcode解析器可以正确处理嵌套的shortcode宏:
您需要递归调用do_shortcode()
在任何可能包含嵌套短代码的短代码处理程序上。例如:
function wpse18659_permalink( $atts, $content ){
return \'<a href="\' . get_permalink() . \'" title="Permalink to \' . get_the_title() . \'" alt="">\' . do_shortcode( $content ) . \'</a>\';
}
add_shortcode( \'permalink\', \'wpse18659_permalink\' );
这应该可以很好地处理嵌套的短代码。如果您熟悉此代码<?php $pattern = get_shortcode_regex(); preg_match(\'/\'.$pattern.\'/s\', $posts[0]->post_content, $matches); if (is_array($matches) && $matches[2] == \'YOURSHORTCODE\') { //shortcode is being used }&#