• Resolved Compote13

    (@compote13)


    Hello there,

    First time for me, please excuse my approximate english.

    I have a website in local for a while and I can’t get to work one of the feature i wanted for it. The feature : get the category ordered by the date (of the last post in this category)

    Let me explain, i have 5 main categories (say Local News, Arts, Music, Itw and Misc for exemple).
    I have a loop in the index that retrieve the 2 last posts of each category but with 5 queries. (wich is…not great for now)

    $args = array(
    'cat' => 1273, //i change the cat id - this is the value that needs to be variable in my future query
    'showposts' => 2,
    'orderby' => 'date',
    'order' => 'DESC',
    'post__not_in' => $latest->posts //i have a slider and do not want my posts to be in double
    );
    $the_query = new WP_Query($args);
    if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
    
    etc

    I want this order to change regarding the last post date of each category.

    Lets say i had yesterday :
    -Local News posts
    -Arts posts
    -Music posts
    -Itw posts
    -Misc posts

    Today if i post in Music :
    -Music posts
    -Local News posts
    -Arts posts
    -Itw posts
    -Misc posts

    And tomorrow if i post in Misc :
    -Misc posts
    -Music posts
    -Local News posts
    -Arts posts
    -Itw posts

    And so on.

    I hope my issue is understandable.

    I search for a while now how to do it but it seems that nobody ever wanted to do it, or had any trouble while doing it at least !

    Can anyone help me on this one ?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get category ordered by last post date’ is closed to new replies.