Skip to main content
8 events
when toggle format what by license comment
Oct 28, 2016 at 7:20 comment added sizer I see what you mean, but I lack the skills at the moment to write it properly. Maybe you could give me more hints? I will keep trying, but get errors. Thanks! S
Oct 27, 2016 at 14:44 comment added Sebastian Kaczmarek 1. The content is always the same because the_content(); must be inside while loop. 2. In the content.php file give an if statement which checks if current post is the latest one (or simply if next_post_link() == ''). If it does, do another WP_Query with the same arguments but set 'order'=>'ASC'. This will return you one-element array with the very first post. Then just take its permalink and echo it as a href attribute in <a> tag. Hope you know what I mean
Oct 27, 2016 at 14:23 comment added sizer Two problems. 1. The content text is always the same on every post. 2. The cycling is not complete. It will not link back to the latest post, to create an endless post cycle. S Edit: I used <?php echo get_permalink( get_adjacent_post( false, '', true ) ); ?> for next post link url.
Oct 27, 2016 at 14:21 comment added sizer Thanks again Sebastian! I wrote all the code to index.php, this is how it looks. <a href="<?php echo get_permalink( get_adjacent_post( false, '', true ) ); ?>"> <span class="next"></span> <div class="featured-image" style="background-image: url('<?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?>')"></div> </a> <div class="content"> <?php $query = new WP_Query( array( 'posts_per_page' => '1', 'order' => 'DESC', 'orderby' => 'date' ) ); while($query->have_posts()){ $query->the_post(); } ?> <?php the_content(); ?> </div>
Oct 27, 2016 at 12:52 comment added Sebastian Kaczmarek I see what you want to achieve. Try doing this: In your main php file (I guess it's index.php) do something similar to this: <?php $query = new WP_Query( array( 'posts_per_page' => '1', 'order' => 'DESC', 'orderby' => 'date' ) ); while($query->have_posts()){ $query->the_post(); } ?> <div><?php the_post_thumbnail(); ?></div> <div class="content"><?php the_content(); ?></div> next_post_link(); <?php } ?> Then in your content.php file write this: <?php the_content(); next_post_link(); ?> I hope you know what I mean. It's quite complicated but it works for me
Oct 27, 2016 at 11:15 comment added sizer Thanks Sebastian, but no help! What I need is one post (feature image+content text) per page. When you click on feature image for example, then next post loads per page. When the last post (by adding date) appears, clicking on feature image loads the first post again. One post per page. Infinite cycle of posts by adding date, starting with the latest post added. Hopefully that explains my needs! S
Oct 27, 2016 at 10:05 comment added cowgill That's what I thought as well but the answer seemed too easy. :-)
Oct 27, 2016 at 9:57 history answered Sebastian Kaczmarek CC BY-SA 3.0