| | #1 |
| Warrior Member Join Date: 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
I have sticky posts on my site and this code doesn't work properly because of them. How can i show only recent posts on sidebar with codes. PHP Code: |
| |
| | #2 |
| Active Warrior Join Date: 2016
Posts: 45
Thanks: 37
Thanked 10 Times in 10 Posts
|
The code seems to be fine. Be sure to run it after the post content is displayed, not before.
|
| |
| | #3 |
| Web Designer Join Date: 2013
Posts: 70
Thanks: 0
Thanked 19 Times in 18 Posts
|
Try this code, I have not tested it. <?php $args = array( 'post__not_in' => get_option( 'sticky_posts' ), 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC' ); $posts = get_posts($args); ?> <ul> <?php foreach($posts as $post):?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; wp_reset_postdata();?> </ul> |
| |
| | #4 |
| Senior Web Developer Join Date: 2016 Location: Bangladesh
Posts: 16
Thanks: 0
Thanked 3 Times in 3 Posts
|
You can install a plugin 'Recent post plugin' which will show your recent posts to your sidebar.
|
| | |
| |
|
| Bookmarks |
| Tags |
| posts, recent, show, sidebar, wordpess |
| |