Monday, 15 April 2019

4 Easy Ways to Re-Order Blog Posts in WordPress (Step by Step)

Do you want to change the order of your blog posts in WordPress?

By default, WordPress displays your blog posts in reverse chronological order (newer posts first), but sometimes you may need to move specific posts up or down.

While it may feel like there is no way to do this in WordPress, you’ll be surprised to learn how easily you can change post order using multiple ways.

In this article, we will show you 4 different ways to re-order blog posts in WordPress. You can pick a solution that looks easier and fits your needs.

Ways to easily re-order blog posts in WordPress

Why Re-order Blog Posts in WordPress?

If you are just starting a blog, then you will not need to re-order your blog posts right away. However as your content grows, you may want to explore different ways to promote content across your website.

One of them is to make specific posts more prominently displayed on the front page, blog page, recent posts, or archive pages.

Now the problem is that WordPress normally displays your blog posts in a reverse chronological order. There is no option to simply just move a post up and down.

Does this mean you cannot bring your older articles to the front page? Or remove a newer article from the recent posts?

No, not at all.

There are multiple workarounds that let you do just that. Depending on your needs, you can choose the method that suits your requirements.

Let’s take a look at some of the ways you can easily re-order blog posts on your WordPress site.

1. Change Post’s Published Date

This is the easiest method and allows you to re-order posts using the built-in WordPress functionality.

As you know that WordPress displays posts based on their publish date in reverse chronological order (newer posts first). Changing a post’s publish date will also change where it appears in the list.

Reorder posts by changing published date

For example, if you wanted to bring an older post up, you would have to change its date to be newer. Similarly if you wanted to move a post down, then you can change its date to be older.

Simply edit the post you want to reorder and on the post edit screen click on the publish date under the Document panel.

Change publish date for a blog post

This will bring up a date and time popup where you can change the post’s published date and time. After you have changed the date/time, click on the ‘Update’ button to save your changes.

You need to select a date relevant to other posts.

For example, if you wanted to display an older post before another post that was published on 8 March, then you need to change the post’s publish date to 9 March.

Post moved up

2. Use Post Types Order Plugin (Drag and Drop Option)

If you want to re-order posts but don’t want to change their publish dates, then this method is for you.

First, you need to install and activate the Post Types Order plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Settings » Post Types Order page to change plugin’s settings.

Post Types Order settings

From here, you need to select the post types where you want to enable the plugin. After that, simply click on the ‘Save settings’ button to store your changes.

Now you can just go to Posts » All Posts page and simply drag and drop posts to re-order them.

Reorder blog posts by drag and drop

3. Use Sticky Posts Feature in WordPress

Many users just want to reorder blog posts to highlight a blog post as featured content. WordPress comes with a default feature to achieve that, and it’s called Sticky posts.

Sticky posts feature allows you to highlight a post on top of all other posts on your blog page.

Simply edit the blog post that you want to pin to the top. On the post edit screen, check the box next to ‘Stick to the Front Page’ option under ‘Document’ panel.

Make a post sticky in WordPress

After that, click on the ‘Update’ button to save your changes.

You can now visit your website, and you will see the selected post pinned to the top. Depending on your theme, your sticky post will be highlighted differently.

Sticky post highlighted in WordPress

4. Modify WordPress Query using Code (Advanced)

This method requires you to add code to your WordPress site. If you haven’t done this before, then see our guide on how to copy and paste the code in WordPress.

If you are an advanced user and want to customize the post order, then you can modify the default WordPress query.

For example, take a look at this code snippet. It allows you to display posts in chronological order (older posts first).

//function to modify default WordPress query
function wpb_custom_query( $query ) {

// Make sure we only modify the main query on the homepage      
        if( $query->is_main_query() && ! is_admin() && $query->is_home() ) {

                // Set parameters to modify the query
                $query->set( 'orderby', 'date' );
                $query->set( 'order', 'DESC' );
        }
}

// Hook our custom query function to the pre_get_posts 
add_action( 'pre_get_posts', 'wpb_custom_query' );

This code simply modifies the orderby and order parameters in the default WordPress query.

However, this code may sometimes not work as expected due to some plugins or theme already modifying the default query. To fix that, you can use the supress_filters parameter like this:

//function to modify default WordPress query
function wpb_custom_query( $query ) {

// Make sure we only modify the main query on the homepage      
        if( $query->is_main_query() && ! is_admin() && $query->is_home() ) {

                // Set parameters to modify the query
                $query->set( 'orderby', 'date' );
                $query->set( 'order', 'DESC' );
                $query->set( 'suppress_filters', 'true' );
        }
}

// Hook our custom query function to the pre_get_posts 
add_action( 'pre_get_posts', 'wpb_custom_query' );

The oderby parameter comes with many options. See the full list of options on the WP Query codex page.

We hope this article helped you learn easy ways to re-order blog posts in WordPress. You may also want to see our ultimate list of most wanted WordPress tips and tricks that you can use on your blog.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post 4 Easy Ways to Re-Order Blog Posts in WordPress (Step by Step) appeared first on WPBeginner.



source https://www.wpbeginner.com/plugins/reorder-wordpress-posts-using-drag-drop/

1 comment:

  1. "To get all your Product development requirements covered with the latest technological advancements such as Salesforce , IoT , Blockchain , NFT Marketplace Development Company
    Cloud Service , Mobile & Web development for your business. Hashstudioz Technologies brings you some of the leading solutions to Upgrade and Upscale your Business."

    ReplyDelete