ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Sorting of Posts by Author

April 13, 2009 11:41am

Subscribe [2]
  • #1 / Apr 13, 2009 11:41am

    kc4imr

    9 posts

    Hello All,

    I have put together a page that pulls in and displays several upcoming posts by a certain author on my site.

    The problem I am having is in sorting the posts in the correct manner. I would like to display the author posts, starting with today’s date (Day1), followed by the next 7 days (Day1, Day2, Day3…Day 7) of posts. I have been able to pull this in, but when displayed, it starts with the last Day7 and works back to Day1 (Day7, Day6, Day5…Day1).

    I have tried the sort from “asc” to “desc”, it simply starts with their first post, which may have been 6 months ago and displays 7 from that point. Below is the code I am using…

    {exp:weblog:entries weblog="weblog" author_id="{segment_2}" start_on="{current_time format='%Y-%m-%d'}"  week_sort="desc" show_future_entries="yes" dynamic="off" limit ="7"}
    <h2>{title}</h2>
    
    <p>{summary}<br />
    {body}<br />
    {/exp:weblog:entries}

    Any help would be more than appreciated!

    Thanks

  • #2 / Apr 13, 2009 1:46pm

    Arun S.

    792 posts

    I’m a little confused about what’s actually happening, but try adding the sort= parameter in addition to the week_sort= parameter.

  • #3 / Apr 13, 2009 2:03pm

    kc4imr

    9 posts

    No such luck with adding the sort = parameter. Would it help if I provided more information? If so, what can I provide?

    Cheers,

  • #4 / Apr 13, 2009 2:10pm

    Arun S.

    792 posts

    I’m not sure if this would make a difference, but you’re using the week_sort= parameter, without using he display_by=“week” parameter.  You need the display_by=“week” parameter for the week_sort= to work.

    Also, if you’re using start_on=”{current_time}”, it won’t show entries from the past. Is that what you’re trying to do?  Are you trying to display today’s posts plus posts for the NEXT (i.e. upcoming) week?

  • #5 / Apr 13, 2009 2:21pm

    kc4imr

    9 posts

    Thanks for the help!

    I do want to only show today’s entries and the entries for the next week, I do not need to show any past entries.

    I played around with the pieces and still no luck…

    I have added the display_by=“week” parameter and tried multiple combinations of “asc” and “desc” with the week_sort= and sort=, but it still lists it as Day7,Day6,Day5…Day1

    Here is the current code:

    {exp:weblog:entries weblog="fcbc" author_id="{segment_2}" start_on="{current_time}"  display_by=“week” limit ="7"  week_sort="desc" sort = "desc" show_future_entries="yes" dynamic="off" }

    Thanks again!

  • #6 / Apr 13, 2009 3:35pm

    Arun S.

    792 posts

    Ok, one step at a time.  Taking the display by week out of the equation, does the below sort them in the correct order for you.

    {exp:weblog:entries weblog="fcbc" author_id="{segment_2}" start_on="{current_time}"  limit="7"  sort="asc" show_future_entries="yes" dynamic="off" }

    This should show you the 7 oldest, sorted so the oldest is first.  Assuming these are the 7 posts you want to display, is this the order they should be in?  Or is it the opposite (i.e. sort=“desc”)

  • #7 / Apr 13, 2009 3:53pm

    kc4imr

    9 posts

    You are correct…

    That has sorted the 7 oldest entries starting with the oldest.

  • #8 / Apr 13, 2009 3:59pm

    Arun S.

    792 posts

    What does this get you?

    {exp:weblog:entries weblog="fcbc" author_id="{segment_2}" start_on="{current_time}"  sort="asc" show_future_entries="yes" dynamic="off"   display_by="week" limit="1" show_future_entries="yes" show_current_week="yes"}
  • #9 / Apr 13, 2009 4:29pm

    kc4imr

    9 posts

    Arun S. YOU ARE THE BEST!!!

    That worked perfectly!!

    Thanks so much for working with me on this, your help is much appreciated!

  • #10 / Apr 13, 2009 4:32pm

    Arun S.

    792 posts

    Awesome!  Glad I could help. 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases