• 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

Custom Post Order

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 › Custom Post Order

This topic is: resolved

Tagged: custom order, customizing home page., post id, Post Order

  • This topic has 9 replies, 3 voices, and was last updated 7 years, 9 months ago by Brad Dalton.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • June 22, 2015 at 11:58 am #157178
    James D
    Member

    Hello:

    I have a site that I am migrating over to my Genesis Theme; Modern Portfolio Pro.

    I am going to include links to the existing site and the migration site that I am working on so that you can see the difference.

    The original site is http://theAmericanPresidents.org , and just as you would suspect has a listing of posts based on the each president. I was able to customize the order of the posts, so that the presidents show up in their numeric order 'George Washington first, Barack Obama last.

    I am able to do this in the original non-genesis them by using this plug in. 'Simple Custom Post Order'

    Unfortunately, this does not seem to work with the Modern Portfolio them and the new version of the site. Perhaps because the posts are controlled by a widget?

    The working site 'builder.theAmericanPresidents.org' does not respond that plugin 'Simple Custom Post Order'. I thought perhaps it could be controlled by setting the POST ID for each blog post. But I don't know where to find it.

    Basically I am looking for a way to keep all these blog posts on main page using their featured image as a thumbnail, and make it so that order does not change, regardless of whether I update the individual posts.

    Thanks

    Jim

    http://builder.ThAmericanPresidents.org
    June 22, 2015 at 12:41 pm #157181
    Brad Dalton
    Participant

    Use pre_get_posts https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts


    Tutorials for StudioPress Themes.

    June 22, 2015 at 1:10 pm #157185
    James D
    Member

    Oh boy, that is above my pay grade. I don't know what that means.

    Just when I think I am understanding this stuff, I realize that I have no idea how most of this stuff works.

    Jim

    June 22, 2015 at 1:22 pm #157187
    Brad Dalton
    Participant

    Using a code editor, add to the end of your functions file.

    function modify_query_order( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'orderby', 'title' );
            $query->set( 'order', 'ASC' );
        }
    }
    add_action( 'pre_get_posts', 'modify_query_order' );
    

    Tutorials for StudioPress Themes.

    June 22, 2015 at 2:31 pm #157204
    James D
    Member

    uhmm. yeah... I added that code to the very end of my functions.php

    function modify_query_order( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( 'orderby', 'title' );
    $query->set( 'order', 'ASC' );
    }
    }
    add_action( 'pre_get_posts', 'modify_query_order' );

    and it broke my site.

    June 22, 2015 at 2:39 pm #157206
    James D
    Member

    This is the last few lines of the php code. By the way, I am really out of my element with php. I can find my way through css without too much problem, but the php stuff loses me.

    Here is the code as I pasted it in my file from the * Register Widget Area * on down:

    //* Register widget areas

    genesis_register_sidebar( array(

    'id' => 'home-about',

    'name' => __( 'Home - About','mpp' ),

    'description' => __( 'This is the about section of the homepage.','mpp' ),

    ) );

    genesis_register_sidebar( array(

    'id' => 'home-portfolio',

    'name' => __( 'Home - Portfolio','mpp' ),

    'description' => __( 'This is the portfolio section of the homepage.','mpp' ),

    ) );

    genesis_register_sidebar( array(

    'id' => 'home-services',

    'name' => __( 'Home - Services','mpp' ),

    'description' => __( 'This is the Services section of the homepage.','mpp' ),

    ) );

    genesis_register_sidebar( array(

    'id' => 'home-blog',

    'name' => __( 'Home - Blog','mpp' ),

    'description' => __( 'This is the Blog section of the homepage.','mpp' ),

    ) );

    function modify_query_order( $query ) {

    if ( $query->is_home() && $query->is_main_query() ) {

    $query->set( 'orderby', 'title' );

    $query->set( 'order', 'ASC' );

    }

    }

    add_action( 'pre_get_posts', 'modify_query_order' );

    I am getting errors in Dreamweaver on these 3 lines

    if ( $query->is_home() && $query->is_main_query() ) {

    $query->set( 'orderby', 'title' );

    $query->set( 'order', 'ASC' );

    Jim

    June 22, 2015 at 5:31 pm #157226
    coralseait
    Member

    You are missing your closing brace on your if block:

    this

    if ( $query->is_home() && $query->is_main_query() ) {
    
    $query->set( ‘orderby’, ‘title’ );
    
    $query->set( ‘order’, ‘ASC’ );

    should become

    if ( $query->is_home() && $query->is_main_query() ) {
    
    $query->set( ‘orderby’, ‘title’ );
    
    $query->set( ‘order’, ‘ASC’ );
    }

    Notice the if block closing brace.

    Also, very important, but your ticks are wrong if that's exactly what you pasted in. You have to be very careful about the quoting when pasting from websites. You'll get back ticks or wrong tick instead of just ticks (single quote). You'll probably just need to go through and change every bad tick to the correct one (for example around orderby, title, order, ASC

    Note, this is a very common problem when pasting code directly from forums / browsers.


    Coral Sea IT

    June 23, 2015 at 2:11 am #157264
    Brad Dalton
    Participant

    The code works. Did you use a code editor or the theme editor to add the code?


    Tutorials for StudioPress Themes.

    June 24, 2015 at 10:29 am #157415
    James D
    Member

    I guess I was missing a brace.

    Someone above says my 'ticks' are wrong. Sorry I don't know what a 'tick' is.

    I was editing the code in dreamweaver 2015

    jim

    June 24, 2015 at 10:36 am #157416
    Brad Dalton
    Participant

    You need to use a PHP code editor like Notepad++ for Windows or Text Wrangler for Mac and paste the code into the file using FTP.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Custom Post Order’ is closed to new 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