Reversing Sort Order in Main Blog Loop

Home Forums Calendar Products Events Calendar PRO Reversing Sort Order in Main Blog Loop

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #195626
    stanislaus
    Participant

    Hi, am using this code provided from your tutorial and is working nice, but the sort order doesn’t match as the calender and need help on how I can reverse the sort order… not sure whether it can be done on this same code or do I need to do it on WordPress rss template… any pointers helpful..
    ==============
    http://pastebin.com/ymPtLLKj
    ==============

    #198713
    Brook
    Participant

    Howdy stanislaus,

    I can sure help with that! Fair warning, to do exactly what you want will require some programming though.

    First of all, you probably already saw this page. But just in case, Tribe Guide For Customizing RSS. In there you will note that we walk you through adding event start/end times to RSS items. This is usually better than changing the sort order and such.

    WP feeds sort by the pubdate field, as is standard practice. So events are sorted by the date you created/published them, not based on their start date. You no doubt could change this if you so desire, but it breaks the way RSS is intended to work a little bit. Now people who watch you RSS feeds will not necessarily see the newest items you added, rather they will only see the future upcoming ones. If you do not mind breaking RSS expectations, then you could make this customization. To do this: Hook into a wp query filter, like pre_get_posts. Adjust the query to detect is the item has a post meta item _EventStartDate. If so, use that instead of pubdate, if not, use pubdate. Then sort by pubdate. This will be pretty complicated though. You will need a command of SQL to accomplish all of this.

    Does that make sense? Will that work for you? Please let me know. Cheers!

    – Brook

    #199228
    stanislaus
    Participant

    Ok, now I see why…. I better just use the method as explained in the guide, but I need more information on which spot in functions.php do I put this part of the code in tutorial..
    ==============
    http://pastebin.com/hSNfXGE0
    ==============

    Also, do these codes need to be in functions.php too?
    Either way would like to see a working example or
    a ready made functions.php with all the code implemented
    in it so I can study it..am not a coder but studying how
    its all put together would be helpful..

    Thanks..

    ==============
    http://pastebin.com/ymPtLLKj
    http://pastebin.com/VYqsZ9yA
    ==============

    #201012
    Brook
    Participant

    Howdy stanislaus,

    A working functions.php simply needs the following line at the very top:

    <?php

    Then you can put all that other code underneath, perhaps with a few lines between each new block of code. Here is an example. Keep in mind though this example will only work if your theme already has a blank functions.php, if your themes functions.php file is not blank, then you will simply need to copy/paste the code from the article and not add a “<?php” line anywhere. In that case, paste it at the top of your theme’s functions.php file, underneath the first line “<?php”.

    I hope this information helps. Let me know if you have any more questions. Cheers!

    – Brook

    #201359
    stanislaus
    Participant

    Thanks Brook…

    #211566
    Brook
    Participant

    You are of course very welcome stanislaus! I was just closing out some older topics like this one. If you have a minute or two, we would love it if you couldĀ write a few words about the plugin here. Cheers!

    – Brook

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Reversing Sort Order in Main Blog Loop’ is closed to new replies.