Random post order on Category pages without duplicates on other pages

  • Author
    Posts
  • #3071017

    I understand how to use functions.php in my child theme. I need to be able to set up a category with multiple pages that display posts in a random order without repeating them in the other pages. Example I have a 100 posts in a category called Cars. I want to display only 20 car posts per category (Car) page in a random order but across all 5 pages so duplicates do not show up on the next pages. How do I do that? I have tried the coding that starts with add_filter( 'posts_orderby', 'randomise_with_pagination' ); and I have tried `function wpsites_query( $query ) {
    if ( $query->is_category() && $query->is_main_query() ) {
    $query->set( ‘orderby’, ‘rand’ );
    }`
    but either one of them keeps randomizing when you go to the next page. I could even have it randomize just once a day or when we tell it to. I have searched for a plugin…and cannot find one.

    #3071227

    kokkieh
    Staff

    Hi there,

    You didn’t give a site link, but it looks like you’re working with the open source WordPress software found on WordPress.org. Editing the functions.php file is not possible on WordPress.com, and we’re not able to advise you on this here.

    Please post in the self-hosted forums instead. They should be able to help you get this working:

    https://wordpress.org/support/

The topic ‘Random post order on Category pages without duplicates on other pages’ is closed to new replies.