• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Randomize post order on a category blog page

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Randomize post order on a category blog page

This topic is: not resolved
  • This topic has 1 reply, 2 voices, and was last updated 8 years, 4 months ago by Brad Dalton.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • April 14, 2014 at 7:39 pm #100327
    sheilab
    Participant

    Hi,
    I am looking to randomize the order of posts presented on a category blog page. When I add an echo statement to the code below it appears on the page, but the $query is not working. This in on the old Venture theme. Any help would be appreciated.

    //random posts on a category blog page

    add_action( 'pre_get_posts', 'display_random_posts' );
    function display_random_posts( $query ){

    // check for page
    if ( $query->is_page('466')) {

    // set the order to random
    $query->set( 'orderby', 'rand' );
    }

    }

    http://www.luvnbitsnparts.com/sculptural-art/
    April 15, 2014 at 8:37 am #100401
    Brad Dalton
    Participant

    Please paste your code in a Github Gist and link to it or embed it here.

    You would add a conditional tag after the function

    pre_get_posts is the correct function to use


    Recent Client work

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2022 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble