• 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

Possible to modify standard Genesis loop args?

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 › Design Tips and Tricks › Possible to modify standard Genesis loop args?

This topic is: resolved
  • This topic has 2 replies, 2 voices, and was last updated 8 years, 8 months ago by simbasounds.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 9, 2015 at 6:46 pm #136815
    simbasounds
    Member

    As a general question, is it possible to pass an argument to a standard Genesis loop to override theme settings?

    In this case it's a custom taxonomy template and all I want to do is turn off paging and orderby random without rebuilding the loop.

    ie. it's looking great with just the genesis(); function, but needs to be random and all on one page.

    January 9, 2015 at 8:56 pm #136823
    Ren Ventura
    Member

    pre_get_posts() is what you're looking for.

    http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    January 10, 2015 at 2:01 am #136831
    simbasounds
    Member

    Thanks so much Ren. In functions.php I used:

    add_action( 'pre_get_posts', 'set_cat_tax_args' );
    function set_cat_tax_args( $query ) {
    	if ($query->is_tax('charity-category')) {
    		$query->set( 'orderby','rand' );
    		$query->set( 'posts_per_page', -1 );
    	}
    }

    And it's working!

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ 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

© 2023 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