我正在尝试让这个函数与jquery选项卡一起工作,并且我已经让它的一些部分工作起来了。现在,该函数正确地输出
<ul>
<li>item1</li>
<li>item2</li>
etc..
</ul>
但它根本没有发出第二个循环。我对wordpress不是最熟练的,更不用说php本身了,所以我希望能得到一些关于如何正确设置这样一个函数的帮助。function new_function($type=\'new_function\') {
$args = array(
\'post_type\' => \'tabs\',
\'posts_per_page\' => 10
);
//first loop puts out correctly so far.
$firstresult .= \'<div id="tabs">\';
$firstresult .= \'<ul>\';
$firstloop = new WP_Query($args);
while ($firstloop->have_posts()) {
$firstloop->the_post();
$firstresult .=\'<li><a href="#\'.get_the_title().\'">\'.get_the_title().\'</a></li>\';
}
$firstresult .=\'</ul>\';
return $firstresult;
//the second loop does not work at all, but does not break the first part either.
$result .= \'<div id="tabs-container">\';
$loop = new WP_Query($args2);
while ($loop->have_posts()) {
$loop->the_post();
$result .=\'<div class="col-md-12">\';
$result .=\'<div class="quote-content"><blockquote>\'.get_the_content().\'</blockquote></div>\';
$result .=\'<div class="quote-author"><p>\' .get_the_title(). \'</p></div>\';
$result .=\'</div>\';
}
$result .= \'</div>\';
$result .=\'</div>\';
return $result;
}