Anythingslider Update – How to display pages instead of posts

By Matt Dunlap on July 13th, 2010
Tags: , ,

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.

  1. 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);
        }
    
  2. 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
    
  3. 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.


My next post is going to be awesome... Subscribe to my feed so you don't miss it

Large RSS Feed Button


Previous Post Next Post

Post a Comment

Name:   
Email:   
Website:   
Comments:   
alert icon Do you need help with your website? I can offer full system admin, website development and Internet marketing services
Domain Name Deals
.COM for $1.99
With any non domain name purchase
Free Private Registration - When you buy or transfer 5 domains at opendls.com
Domain Name Reseller Accounts
Low buy rates - Very Profitable
Matt Dunlap on Why am I getting redirect loop errors with FireFox 3.6.8?
Hi, thanks for the heads up... Have you experienced this problem with any other websites? It's reall[...]
Stacy on Why am I getting redirect loop errors with FireFox 3.6.8?
I was attempting to follow your links to these tutorials from your youtube video, and I was using th[...]
Matt Dunlap on 301 redirects will lower your Google Pagerank
You want 301 redirect on same site redirects mainly to eliminate duplicate content. For example, if [...]
Kate Mag on 301 redirects will lower your Google Pagerank
great info. Does this mean that only affecting 301 redirect to another domain. I have 301 redirect t[...]
Mike Johnson - Real Estate Agent on Why is making extra money a bad habit?
Hey man, this is some great stuff. The only thing I can't figure out is why this sort of thing isn'[...]

Top Guest Bloggers

LoneWolf
View Posts | RSS

Guest Bloggers Welcome!


Powered By: Free Premium WordPress Theme | Copyright 2007 - 2010 mattdunlap.org Sitemap