Community Forums › Forums › Archived Forums › Design Tips and Tricks › Need code to sort by time and category
- This topic has 7 replies, 3 voices, and was last updated 6 years, 6 months ago by Brad Dalton.
-
AuthorPosts
-
October 20, 2017 at 7:25 am #212734sdsParticipant
My site aggregates article links. I have 25 article links listed at a time. Within those 25 articles, I would like to have any article that is from a free site be listed on top and those behind a paywall listed afterwards (paywall articles have the category "paywall", but I could change this architecture if there was an easier way). Within the free and paywall sections, the article links would be listed by time of entry as normal.
I'm using Lifestyle-pro and on the latest WP release.
Does anyone have a code snippet that would modify the loop this way?
October 20, 2017 at 7:45 am #212736Victor FontModeratorWhat you want to do is possible, but it sound to me like you may have to hire a developer. From what you describe, you need a custom loop and quite possibly a custom SQL statement. Both of these require a deeper look at the architecture, maybe access to the database, and several hours to a day to construct and test. That's way beyond the scope of help that community volunteers are generally able to provide for free. There might be someone here that can help, but I really the fastest route to finding your solution is to hire someone.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?October 20, 2017 at 7:51 am #212740sdsParticipantA wordpress coder could do this in 5 minutes. I thought I would check here first before I went to Stackoverflow. If there aren't many coders here, I can try elsewhere. Thanks.
October 20, 2017 at 7:54 am #212742Victor FontModeratorNo. I am a full-stack coder with over 30 years of application development experience. Custom SQL does not take 5 minutes. Changing loop parameters takes more than 5 minutes as well since what you want requires adding a taxonomy query as well. Good luck finding someone.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?October 20, 2017 at 8:16 am #212747sdsParticipantI'm fully aware of what is involved. This problem is not hard. Any professional wordpress developer who needs a full day of development on this, I would avoid like the plague.
October 20, 2017 at 8:41 am #212748Brad DaltonParticipantNever seen this done before with external content.
Modifying the WP_Query can de done with pre_get_posts or genesis_custom_loop which may simply require a small snippet however your situation may be different because its external content.
October 20, 2017 at 9:05 am #212749Brad DaltonParticipantUnless your file contains a new WP_Query in which case you can use any WP_Query parameters, i think you would need 2 loops.
If you can do this quickly, please share your solution.
October 20, 2017 at 10:43 am #212754sdsParticipantI store the url/name in custom fields. I posted this to stackoverflow and received two answers within an hour:
https://stackoverflow.com/questions/46851570/wordpress-query-that-sorts-by-category-and-time
I wanted to try here first, so that other StudioPress customers could benefit.
-
AuthorPosts
- The topic ‘Need code to sort by time and category’ is closed to new replies.