+1 289 214 7531

Direct Call

By Mail

17-7000 McLeod Road, Suite #202, Niagara Falls, Ontario, L2G 7K3, Canada

Opening Hours

9:00 a.m. - 5:00 p.m. Eastern Time Zone

WordPress: Sorting your Pages and Posts

12 May

WordPress: Sorting your Pages and Posts

If you have been using WordPress and updating content for a long time like us, you’ll find that you’ve got many hundreds of pages and posts on your site.

When, using the dashboard at the back-end you check on your pages and posts you will see them sorted into Alphabetical order by title.

Sure you can re-sort them by clicking on the date column twice, but this is an uneceesary step that can be quickly fixed with a few lines of code in your Theme folder.

Our assumption is that you’ve created a Child theme to tailor your site, but irrespective of that or not, the same applies to have your pages on posts sorted in a different order.

In the dashboard, using the Appearance -> Theme Editor option, you will be presented with an Edit Themes page.

Depending upon the theme used your page will look something like this:

On the right-hand side, you will see a section called Theme functions (underneath will identify the actual .php file, usually functions.php.

Clicking this will bring up the file in the online editor. By scrolling to the bottom and adding the following code, you can change the sort order of the All Pages and All Posts page to sort in Date order.

add_filter('pre_get_posts', 'my_set_post_order_in_admin' );
function my_set_post_order_in_admin( $wp_query ) {
	global $pagenow;
	if ( is_admin() && $_GET['post_type'] == 'page' && 'edit.php' == $pagenow && !isset($_GET['orderby'])) {
		$wp_query->set( 'orderby', 'date' );
		$wp_query->set( 'order', 'DESC' );
	}
}

Entering this code at the foot of the file and clicking the Update File button and the sort will be you new default.

If you do not have the permissions to use the built-in WordPress theme editor, you will have to make the changes to the theme functions.php outside of WordPress using either your hosting provider’s file manager or via a file editor after connecting to your server via SSH or Telnet.

If you feel this may be a little too technical for you, you can always call us to provide support for you.

[forminator_form id=”77″]

Leave a Reply

bocoran slot gacor hari ini slot bonus new member 100 didepan situs slot online gacor hari ini situs slot online gacor slot online gacor Link Daftar Situs Slot Deposit Via Dana Situs slot bonus new member 100 persen Slot Online Gacor Hari Ini Di Indonesia RTP Slot Gacor Anti Rungkat Rajanya Judi Slot Online Slot Gacor Deposit via OVO Slot Gacor Deposit via Dana Situs Slot Bonus New Member 100 Di Awal Daftar Situs Judi Slot Online Gacor Pragmatic88 arena slot idn slot pulsa jaringbet slot joker123 deposit pulsa Slot Bonus 100 slot dana slot pulsa Slot Deposit Pulsa slot deposit ovo Slot Online Gacor kakek slot situs judi slot dana Situs Slot Bonus New Member 100 di Depan slot bonus 100 di depan LInk Slot Online Server Singapore LInk Slot Online Server Sydney LInk Slot Online Server Manila LInk Slot Online Server Ukraina LInk Slot Online Server Indonesia LInk Slot Online Server New Zealand LInk Slot Online Server Canada LInk Slot Online Server UK LInk Slot Online Server Vietnam Gala288 Anti Rungkat Situs Slot Online Deposit 10 Ribu Via Dana Terpercaya Situs Slot Online Gacor Hari ini Gampang Menang Maxwin Link Slot Gacor Hari Ini hongkong pools Prediksi Togel pengeluaran sgp live draw hk data hk data sdy live draw sdy