问问题
2723 次
3 回答
1
短代码处理函数的返回值被插入到帖子内容输出中以代替短代码宏。请记住使用 return 而不是 echo - 任何被回显的内容都将输出到浏览器,但不会出现在页面上的正确位置。
在应用 wpautop 和 wptexturize 后格式后解析简码(但请参阅下面关于 2.5.0 和 2.5.1 差异的注释)。这意味着您的短代码输出 HTML 不会自动应用大引号、添加 p 和 br 标签等。如果您确实希望格式化短代码输出,则应在从短代码处理程序返回输出时直接调用 wpautop() 或 wptexturize()。
wpautop 识别简码语法,并会尝试不将 p 或 br 标记包装在独立于一行的简码周围。旨在以这种方式使用的简码应确保将输出包装在适当的块标记中,例如 p 或 div。
于 2011-10-21T15:45:58.107 回答
0
为什么不将 url 选项添加到简码中?
像添加:
function mm_jasmineSays( $atts ) {
extract( shortcode_atts( array(
"quote" => '',
"url" => '',
), $atts ) );
然后添加
<a href="'.$url.'"> <h2>Jasmine says...</h2></a>
也许它可以工作..或者使用 $output 代替返回:
global $post;
$output .= '<div class="jasmine-says">';
if($quote !== '')
$output .= '<a href="'.$url.'"><h2>Jasmine says...</h2>';
$output .= '<div class="jasmine-says-quote">'
$output .='<p><img src="'.get_bloginfo( 'template_directory' ).'/imgs/shortcodes/quote-1.jpg" /></p>';
$output .='<p class="quote">'.$quote.'</p>';
$output .='<p><img src="'.get_bloginfo( 'template_directory' ).'/imgs/shortcodes/quote-2.jpg" /></p>';
$output .='</div>';
$output .='</div>';
于 2013-07-23T18:20:34.997 回答
0
不确定这是否会有所帮助,但您是否尝试过将外部引号更改为单引号?
[jasminesays quote='blah <a href="#">de</a> blah']
或删除内部引号?
[jasminesays quote="blah <a href=#>de</a> blah"]
于 2011-12-22T19:01:43.977 回答