By default, posts in Wordpress are organized by thechronologyNew to old display. Sometimes we may want therearrangeThis content, such as putting important announcements, promotions, or the latest blog postsPut it at the top of the home page. If you want to reorder posts in WordPress, there are a variety of ways to help you do this, including ways to use date sorting, top posts, plugins, and drag and drop functionality.
In this article, we'll go over some of the most commonly used solutions to help you reorder posts and products in WordPress.
Different ways to reorder posts in WordPress
Edit or change the date of posting
This is one of the easiest ways to do it. Since WordPress sorts posts in reverse chronological order by default, you can change the order in which they are displayed by simply changing the post's publish date.
Operational Steps:
- Step 1: Open the WordPress dashboard and find the post you want to reorder.
- Step 2: ClickQuick Editmaybecompiler, Quick Edit can be changed at the date of the pop-up window. Clickcompiler, make changes when you go to the article page.
- Step 3: Change the date and time. For example, if you want an old post to come before the latest post, simply change its date to today.
- Step 4: Save changes. After reloading the page, you will see the posts show up in the list by the new date in the appropriate place.
This approach is good for quickly reordering a small number of posts, but if multiple posts need to be reordered frequently, a more flexible approach may need to be considered.
Setting a post as a top post
WordPress provides a "top" feature that allows you to pin a specific post to the top of your blog page regardless of the date it was published. Top posts are good for highlighting key announcements or promotions.
Operational Steps:
- Step 1: Open the WordPress backend and find the post you wish to top.
- Step 2: ClickQuick EditFind "Top this article" option, check the box.
On the article editing page, in the right columnvisibilitySelect Edit and check the box "Place articles at the top of the home page".
- Step 3: Save and update the post. At this point, the post will be displayed at the top of the blog page, again you can uncheck this option.
take note of: The appearance and style of the top post may vary depending on your theme, and some themes may highlight the top post.
Reordering Posts with the WordPress Plugin
If there is a need to reorder a large number of posts or WooCommerce products on a larger scale, plugins may be the best option. Plugins such as "Post Types Order"It can help you get through the simpledrag-and-drop (computing)The operation customizes the order of the content.
Operational Steps:
- Step 1: In the WordPress dashboard, navigate to "Add New Plugin"page, search for and install "Post Types Order"Plugin. Activate the plugin after installation.
- Step 2Navigate to "Settings" and find "Post Types Order", to enter the plugin settings page, where you can select the type of content (e.g., blog posts, products, etc.) for which you want to enable the drag-and-drop sorting feature.
- Step 3: When enabled, navigate to "All Posts" page, you can see that next to each post is aDrag the icon. Simply click and drag the post to your desired location and the system will automatically save the sort.
This plugin is very flexible and works with almost all custom post types, which is especially handy when you need to sort a large number of posts.
Sorting WooCommerce Products with Drag and Drop
If you use WooCommerce to manage your online store, you may want to manually reorder your products to highlight the best-selling or promotional items.WooCommerce provides a built-in drag-and-drop sorting feature.
Operational Steps:
- Step 1: Navigate to the "Products" "All Products" page.
- Step 2: At the top of the page, find and click on "arrange in order"Button.
- Step 3: Reorder items in the product list by dragging them.
In this way, the order in which products are displayed in the store can be quickly adjusted.
Reorder WordPress Posts with Custom Code
If you wish to fully customize the sorting logic of WordPress posts and have some knowledge of the code, you can use theCustom PHP codeto modify the WordPress query logic. Below is a simple code sample for a scenario where you want to sort posts in ascending order by date.
Operational Steps:
- Step 1: Open WordPress dashboard and install and activate "WPCode"Plugins.
- Step 2: Go to the "Code Snippets" page and select "Add Code Snippet" to add PHP code.
- Step 3: Enter the following code:
function custom_post_order( $query ) { if ( $query->is_main_query() && ! is_admin() ) { $query->set( 'orderby', 'date' ); $query->set( 'order', 'ASC' ); } } add_action( 'pre_get_posts', 'custom_post_order' );
- Step 4: Save and activate the code snippet. This code will reorder all posts in WordPress so that older posts come first.
Please note.Custom code manipulation requires cautionAny error can cause the site to crash. If you are not familiar with code writing, it is recommended to use a plugin or ask a professional developer for help.
reach a verdict
Reordering WordPress posts is an important step in enhancing the user experience, highlighting key content, optimizing SEO and improving the structure of your website. ByWP self-taught website builder, you can choose to simply sort by date, use a plugin, or customize the code, each method has its own unique application scenario. Choosing the right method based on your website's needs will help you better manage and display content.