Order of slides in Suffusion Featured Content

Sep 132013
 Posted by on 13/09/2013 How-To's Tagged with: , ,  Add comments

The problem: “Everything is working great except that I can’t for the life of me figure out how to control the order of the entries in the slider.”

WP_Query Prameters from WordPress Codex
WP_Query Parameters from WordPress Codex

 Yes, Suffusion come with two great Featured Content sliders bundled in it. The first, considered “static”, can be settled at Suffusion Options -> Other Graphical Elements -> Featured Content. Is considered static because can appear only on the top of main column on the pages where is settled to be. The other one, “dynamic”, is the Featured Content Widget. Dynamic because can be used in any widget area, so, can appear anywhere in the page. In this article I will explain how can order the slides in the STATIC slider.

The question from the top of this article was asked several times on the Suffusion Support Forum. Few years ago I also had this problem when we build BHZN site. Then I found a first solution – to change the publishing date of POST. So, I remain with the idea that this is the universal solution and will works for pages too. This was a wrong thought. I start to digg into the code and I discovered more interesting things.

First, and very important, the displaying of slides, including the order is controlled by featured-post.php file from “suffusion” folder. Why is important? The file is pluggable, can be copied into a child theme and edited there for preserving the changes in case of upgrades of theme. Now, studying the file can see that the function which display the slides is suffusion_display_featured_posts($echo = true) and the posts/pages are retrieved by WP_query class instances. Of course, WP_query will accept all allowed parameters specified in Codex: https://codex.wordpress.org/Class_Reference/WP_Query, including ‘order’ and ‘orderby’.

For POSTS is used this query:

 As you can see the ‘orderby’ parameter is not specified – so, is used the default value of this parameter which is ‘date’. So, for changing the order of slides based on posts still works the method of changing publishing date of posts selected as featured. If you need to sort the slides in other order than the date, simply add the orderby paramenter into the query args. By eg. for randomize the slides can change the above line with:

UPDATE: 11 March 2014. The query from above retrieve the latest posts. If you want to retrieve only posts from a single category or tag look for the next code and alter the args used in query:

 By eg., for retrivieng posts by date in ascending order, change the code to:

Can download the file changed to show posts from a category in ascending order from here: featured-posts.php

Now for PAGES is used this query:

Menu Order in Page Attributes panel
Menu Order in Page Attributes panel

Here we can see the ‘orderby’ parameter is present and it’s value is controlled by ‘menu_order’. So, immediately we can see the trivial solution – we can change the order in the Page Attributes panel, on the right of edit area in the Edit Page screen. If you are not happy with this kind of ordering can change the ‘orderby’ parameter. Again, as an example you can randomize the slides by changing the query to:

REMEMBER, before making changes in those queries, make a copy of featured-posts.php from suffusion folder into your child theme folder and edit the copy.

Read this post for learning how to make a child theme.

Note. If you use ‘orderby’ => ‘rand’ as in the above examples, the order of slides is randomized in the moment of page loading and will stay in the initial order until the page is refreshed – you will not see images shuffled at each cycle.

https://drafie-design.nl/order-of-slides-in-suffusion-featured-content/trackback/Trackback URI:  


Experienced web developer and graphic designer. Former consultant for Suffusion theme and former moderator on Suffusion Support forum. I teach others while learning myself.

Google+ Profile

    Google+ Page

 Leave a Reply

(Your comment will be published. To contact me privately, use the contact form.)

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  5 Responses to “Order of slides in Suffusion Featured Content”

Comments (3) Pingbacks (2)
  1. Thanks Drake for coming back.

    The only way I found to make it work was by adding ‘post_type’ => ‘adverts’, ‘cat’ => ‘ad_space’, to latest posts statement just a couple of lines earlier in the script. But the problem with changing these lines is that it effects all sliders the same! So it looked like a more serious mod was required.

    However I have since realised that the slider’s architecture is to off kilter with my needs.

    The point is to display revolving adds, placed over the last month, but It may require a much greater number than the 20 limit imposed in this design. Rather I am thinking Ajax driven replacement of a single post against a query set of all in the last month. But have to give it some thought.

    Thanks anyway.

  2. Hi Andy, thank you for visiting us. But I’m afraid that I can’t help too much this time.

    I don’t use custom post types on any site so my experience in this field is zero. And my advices here or on Suffusion Forum are based only on my experience.

    Another thing – you cannot modify widget codes in a safe manner, the files from /suffusion/widgets/ aren’t pluggable, they cannot be changed in a child theme.

    If this is not a problem for you, you still can try to use the ID’s for your posts in any of the fields for setting post/page ID’s. Then edit /suffusion/widgets/suffusion-featured-posts.php. The actual lines for retrieving the id’s are:

    Try to change ‘post_type’ => ‘post’ or ‘post_type’ => ‘page’ to ‘post_type’ => ‘your-custom-type’.

  3. Hi Drake, I stumbled across your post here when trying to work out how to modify the featured posts widget in order to accommodate a specific taxonomy as the tag ID doesnt seem to work, or it could be the fact that I am using a custom post type. By chance do you know how this might be rectified.

    Hoping to hear
    Andy Seabrook