Limit Slider Posts

  • bryon



    The slider either pulls the 5 most recent posts, or posts form a specific category. THis is good for a ‘feautred’ category, but I’m having a hard time getting my friend (who is doing a bulk of the posting) to set the category for the post to begin with, much less ‘rotate’ the featured category! XD

    I changed the header.php to add this to the ‘get slider posts’ part of the code.

    else {
    $sliderposts = get_posts(array(
    ‘numberposts’ => 10, (This is the new line, and this text is obviously not in the code)
    ‘category_name’ => $slidercat,
    ‘orderby’ => ‘date’,
    ‘order’ => ‘DESC’,
    ‘nopaging’ => true,


    But…well, she ain’t workin’. So I looked up the get_posts command for WordPress, and decided to replace all that mess with this!

    $sliderposts = get_posts(‘numberposts=10&order=DESC&orderby=date%category=$slidercat’)

    But then the whole site broke and wouldn’t work. So..that wasn’t right!

    You can see what the problem is if you look on the home page. The slider is on two rows of icons! I’d like it to show the most recent 5, maybe 10 posts from a specific category (Videos). I’d have it just display the most recent posts in general, but it doesn’t need to show ‘news’ style posts, and I have a category of hidden (and ugly) posts meant to show some videos in a larger screen area — even using the ‘hide post’ plugin, the slider finds them and shows them. D’oh!

    Other than that…the theme is really, REALLY slick. Usually choosing a theme tends to be a labored process, getting one that looks right but also works right. You know how hard it is finding a theme that ‘nests’ the pages correctly in a navbar like that?




    Maybe I’ll use the slider to show a special ‘category’ of posts, each post simple pertaining to each of our series, directors, or what have you. Instead of having it display the most recent videos — which are easily accessed by the navigation, search, or flipping through the blog’s pages — it’ll display in a grandiose fashion each individual or each series that contributes to the site.

    I’d still like to know the trick to getting the slider to show a limited number of posts in one category, if it’s supported. I can’t figure out why limited the number of posts get_posts gets doesn’t work for the category-slier, but does for the non-category-slider. *rubs chin*


    Syahir Hakim


    Try using 'posts_per_page' instead of 'numberposts'

    Tried that again and it doesn’t work. Try removing the 'nopaging' => true instead, and keep using 'numberposts'



    Oh, that did it. Y’know, if I’d looked up what all o those attributes did…it’s clearly documented that enable nopaging disable numberposts.

    Thank you again for the help! d^^

Viewing 4 posts - 1 through 4 (of 4 total)

  • You must be logged in to reply to this topic.