wordpress version: change post orders for different sliders?

grimm's Avatar

grimm

19 Apr, 2013 06:32 AM

I notice you've got one filter that is run for all sliders, correct? Is there any way of determining which slider is making the request and changing the custom sort order for just that specific one? Some way of attaching code to a slider rather than the default query?

  1. Support Staff 1 Posted by Dmitry Semenov on 19 Apr, 2013 11:31 AM

    Dmitry Semenov's Avatar

    Hi,

    The problem with this feature is that such function is not always initiated from slider itself, so I can't pass the ID of slider as a reliable param.

    Hacky way, enter some unique number in "max posts" option and check for it.

    For example, enter 11111 in max posts option of a slider that you want to target, then:

    add_filter('new_royalslider_posts_slider_query_args', 'newrs_custom_query', 10, 2);
    function newrs_custom_query($args) {
        if( isset($args['posts_per_page']) &&  (int)$args['posts_per_page'] == 11111) {
            $args['posts_per_page'] = 5; // change it back to 5
           //  your custom action
        }
        return $args;
    }
    

    Dmitry

  2. Support Staff 2 Posted by Dmitry Semenov on 10 Oct, 2013 05:50 PM

    Dmitry Semenov's Avatar

    Hello,

    Can you please be more specific of what you mean by "but it stop the custom search", what custom search do you mean? Please elaborate.

  3. Support Staff 3 Posted by Dmitry Semenov on 11 Oct, 2013 02:46 PM

    Dmitry Semenov's Avatar

    The problem is that I don't understand why this trick:

    if( isset($args['posts_per_page']) && (int)$args['posts_per_page'] == 7)
    

    isn't working for you? You need just to set a unique number in "Posts per page" input and then check it the if statement.

    Dmitry

  4. 4 Posted by benoit.boulangi... on 14 Oct, 2013 07:55 AM

    benoit.boulangier's Avatar

    Hello Dmitry,

    CAN you explain, i don't understand this hack.

    Best

    Benoit

  5. Support Staff 5 Posted by Dmitry Semenov on 14 Oct, 2013 06:31 PM

    Dmitry Semenov's Avatar

    On edit page of RoyalSlider from posts there is an option called "Posts per page". You put a random unique number in it, and then check for it using the if statement in new_royalslider_posts_slider_query_args filter to target the specific slider.

  6. 6 Posted by benoit.boulangi... on 15 Oct, 2013 11:35 AM

    benoit.boulangier's Avatar

    ok dmitry !
    it's ok, works fine with my query. On my edit page of royal slider, it's not "Posts per page" but "Max Posts".

    Thanks you for your help,
    Best

  7. 7 Posted by rob on 05 Dec, 2013 01:40 AM

    rob's Avatar

    Hi Dmitry,

    I successfully used this on a Post Types gallery.

    Is there any hacky way to target a specific Custom gallery though (using images from my media gallery)? They don't have these options, like the custom posts. Anything else I could set and target?

    I am wanting to set the Wordpress image size for specific kinds of gallery in my WP set up. Hoping to use a mixture of this post's solution, and this...
    http://help.dimsemenov.com/kb/wordpress-royalslider-advanced/wp-usi...

    Thanks

  8. Support Staff 8 Posted by Dmitry Semenov on 05 Dec, 2013 07:09 AM

    Dmitry Semenov's Avatar

    Hi @Rob, you may just render the markup that slider needs via PHP, and initialize it manually too, it's pretty simple, see http://dimsemenov.com/plugins/royal-slider/documentation/#basic-usage

  9. 9 Posted by paudie on 12 Mar, 2014 02:53 PM

    paudie's Avatar

    Hello Dmitry,

    Using the 1111 in the max posts field I was able to call my own custom query where I had set a custom field called 'feature' to true.

    Worked perfectly.

    Thanks

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac