Title: tchaecker's Replies | WordPress.org

---

# tchaecker

  [  ](https://wordpress.org/support/users/tchaecker/)

 *   [Profile](https://wordpress.org/support/users/tchaecker/)
 *   [Topics Started](https://wordpress.org/support/users/tchaecker/topics/)
 *   [Replies Created](https://wordpress.org/support/users/tchaecker/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/tchaecker/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/tchaecker/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/tchaecker/engagements/)
 *   [Favorites](https://wordpress.org/support/users/tchaecker/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Display posts in container, changing per button click](https://wordpress.org/support/topic/display-posts-in-container-changing-per-button-click/)
 *  Thread Starter [tchaecker](https://wordpress.org/support/users/tchaecker/)
 * (@tchaecker)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/display-posts-in-container-changing-per-button-click/#post-5255114)
 * So, after more research I managed to display 5 posts using a shortcode. Now my
   problem is to create working links. Currently the links are working I would add
   it into a page but not inside a div.
 * Any recommendation on how to them work to display the next posts in the div?
 *     ```
       <?php
   
       function myLoop($atts, $content = null) {
       	extract(shortcode_atts(array(
       		"pagination" => 'true',
       		"query" => '',
       		"category" => '',
       	), $atts));
       	global $wp_query,$paged,$post;
       	$temp = $wp_query;
       	$wp_query= null;
       	$wp_query = new WP_Query();
       	if($pagination == 'true'){
       		$query .= '&paged='.$paged;
       	}
       	if(!empty($category)){
       		$query .= '&category_name='.$category;
       	}
       	if(!empty($query)){
       		$query .= $query;
       	}
       	$wp_query->query($query);
       	ob_start();
       	?>
   
       	<div id="newscontainer">
   
       	<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
   
       <div class="news">
         <div class="nachrichten-datum"><p><?php the_date('j. F'); ?></p><h3><?php echo the_title(); ?></h3></div>
         <div class="weiterlesen"><a href="<?php the_permalink() ?>">mehr lesen >></a></div>
       </div>
       <div class="trennlinie"></div>
       	<?php endwhile; ?>
   
       		<div class="news-navigation">
       	  <div class="alignleft"><?php previous_posts_link('« Previous') ?></div>
       	  <div class="alignright"><?php next_posts_link('More »') ?></div>
       	</div>
       	<?php if(pagination == 'true'){ ?>
   
       	<?php } ?>
       </div>
       	<?php $wp_query = null; $wp_query = $temp;
       	$content = ob_get_contents();
       	ob_end_clean();
       	return $content;
       }
       add_shortcode("loop", "myLoop");
       ?>
       ```
   

Viewing 1 replies (of 1 total)