Home › Forums › Calendar Products › Events Calendar PRO › Reversing Sort Order in Main Blog Loop
- This topic has 5 replies, 2 voices, and was last updated 11 years, 11 months ago by
Brook.
-
AuthorPosts
-
May 31, 2014 at 9:34 pm #195626
stanislaus
ParticipantHi, 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
==============June 2, 2014 at 9:01 am #198713Brook
ParticipantHowdy 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
June 2, 2014 at 1:25 pm #199228stanislaus
ParticipantOk, 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
==============June 3, 2014 at 6:52 am #201012Brook
ParticipantHowdy stanislaus,
A working functions.php simply needs the following line at the very top:
<?phpThen 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
June 3, 2014 at 9:08 am #201359stanislaus
ParticipantThanks Brook…
June 7, 2014 at 8:14 am #211566Brook
ParticipantYou 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
-
AuthorPosts
- The topic ‘Reversing Sort Order in Main Blog Loop’ is closed to new replies.
