Support » Fixing WordPress » Change the default value of the "Order" attribute when creating a new Page

  • Hi all,

    When creating a new Page, I’m wondering if it’s possible to change the default value of Order attribute from 0 to 10?

    I wish to do this because a site I am building will have many pages, a link to all of which will be displayed on the home page, and although for the most part they should be sorted in alphabetical order, from time to time there will be pages that should be displayed first

    I aim to achieve this by changing the default ORDER within the main query, as below. So by changing the value of the default Order attribute to 10, I can then manually set up to 10 other pages (0-9) to be displayed first.

    add_filter('posts_orderby', 'gwr_index_posts_orderby', 10, 2);
    function gwr_index_posts_orderby($orderby, $q){
    
    	if(!is_admin() && $q->is_main_query() && ($q->is_home() || $q->is_front_page()))
    		$orderby = 'menu_order ASC, post_title ASC';
    
    	return $orderby;
    
    }
  • The topic ‘Change the default value of the "Order" attribute when creating a new Page’ is closed to new replies.