Anythingslider Update – How to display pages instead of posts
| By Matt Dunlap on July 13th, 2010 |
The Anythingslider WordPress plugin displays the most recent posts by default, but what if you want to display pages instead?
I’m not going to release another plugin with additional display settings because, I’m too busy… But if anyone else wants to jump on the project, I’m more then happy to add you as a contributor.
If you are unfamiliar with the plugin, you can read about here, and I’ve already answered one question about how to display images only in the anythingslider
I think there are 3 possible ways to do this effectively.
- use the WordPress function get_pages();
This is probably all you need. It’s just like get_posts, but if I’m not mistaken it grabs pages instead of posts. I would recommend using this function if you are making a lot of pages that change constantly.This should do the trick. Just change get_posts to get_pages on line 155 in content-slider.php$posts = get_pages('numberposts='.$number_of_posts); foreach($posts as $post) { anything_get_li($post); } - Since the plugin already uses get_posts you can make very minor changes to the arguments passed to the plugin. Currently I only pass the number of posts to return. Get_posts can also take a post_type argument, or include argument. Of course the default post_type is post, but it can be post, page, or attachment… I think with WP 3.0 you can even make you own types, but I haven’t work with any custom types yet.If you use include, you just pass all the page ids. Include will override all other arguments. Since pages shouldn’t change often, this might be a good solution for youMake changes to the arguments as follows
$posts = get_posts('post_type=page&numberposts='.$number_of_posts); //or $posts = get_posts('include=2,5,67,45'); //this will only add 4 pages with the specified IDs - Lastly, you can try to use wp_query… But IMO is overkill for this.
The anythingslider, is simply a list (li) with the content of each post as a list item. You can also go in an create custom, hardcoded list items.




Post a Comment