如果你想在一个页面或帖子中做到这一点,你可以把它做成一个短代码。
[movie-template title="Gone With the Wind" date="1939" image="gwtw.jpg"]
[movie-template title="Citizen Kane" date="1941" image="ck.jpg"]
[movie-template title="Star Wars" date="1977" image="sw.jpg"]
然后在模板的函数中需要一些代码。php,或在自定义插件中:
add_shortcode( \'movie-template\', \'my_movie_listings\' );
function my_movie_listings( $atts ) {
$atts = shortcode_atts(
array(
\'foo_title\' => \'title\',
\'foo_date\' => \'date\',
\'foo_image\' => \'image\',
), $atts );
// $atts[\'foo_title\'] is your movie title
// $atts[\'foo_date\'] is your movie date
// $atts[\'foo_image\'] is your movie image
$ret = "do something here with {$atts[\'foo_title\']}";
return $ret;
}