PHP wp短代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP wp短代码相关的知识,希望对你有一定的参考价值。

// without attributes
function one_half($atts, $content=null){
	return '<div class="one-half">'.do_shortcode($content).'</div>';
}

add_shortcode('one_half', 'one_half');


// attributes
function toggle($atts, $content=null){
	
	extract(shortcode_atts( array( 
							'title' => 'ITEM' 
							), $atts ));
							
	return '<h5 class="toggle-trigger custom"><a href="#">'.$title.'</a></h5>
				<div class="toggle-container">
					<div class="block">
						<p>'.do_shortcode($content).'</p>
					</div>
				</div>';
}
add_shortcode('toggle', 'toggle');

以上是关于PHP wp短代码的主要内容,如果未能解决你的问题,请参考以下文章