There’s no need to set up a new query, just use the first one. Replace:
$loop = new WP_Query( $args2 );
while ( $loop->have_posts() ) {
$loop->the_post();
…with:
$firstloop->rewind_posts();
while ( $firstloop->have_posts() ) {
$firstloop->the_post();
Update: Missed a few other bugs in your code, here’s the complete rework:
function new_function() {
$args = array(
'post_type' => 'tabs',
'posts_per_page' => 10,
);
$result="<div id="tabs">";
$result .= '<ul>';
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) {
$loop->the_post();
$result .= '<li><a href="#' . get_the_title() . '">' . get_the_title() . '</a></li>';
}
$result .= '</ul>';
$result .= '<div id="tabs-container">';
$loop->rewind_posts();
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;
}