tchaecker
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Fixing WordPress
In reply to: Display posts in container, changing per button clickSo, 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)