我一直在研究这个短代码,但没有成功。。。
function loop_shortcode( $atts = \'\' ) {
\'<div class="clear"></div>
<div class="childs grid_12">
<?php
$the_query = new WP_Query(
array(
"post_parent" => "8",
"post_type" => "page",
"posts_per_page" => 4,
"sort_column" => "menu_order"
)
); ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div id="service-hp">
<?php the_post_thumbnail("home-thumb") ?>
<h2 style="margin-bottom:5px"><?php the_title() ?></h2>
<?php the_excerpt() ?>
<a class="read-more" href="<?php the_permalink() ?>">en savoir plus <img src="<?php bloginfo( "template_url" ); ?>/images/read-more.png"></a>
</div> <!-- ends here -->
<?php endwhile; ?>
<?php wp_reset_query() ?>
</div>\';
}
function my_loop_shortcode( $atts ) {
ob_start();
loop_shortcode($atts);
return ob_get_clean();
}
add_shortcode(\'my_loop\', \'my_loop_shortcode\');
I\'m getting no output
我很感激你的帮助提前感谢
UPDATE