Simple Page Ordering

Beskrivning

Sortera dina sidor, hierarkiska anpassade inläggstyper eller andra anpassade inläggstyper som stöder ”page-attributes” med ett enkelt ”dra och släpp”-gränssnitt direkt från den inbyggda listan för sidor.

Dra och släpp sidan till önskad position. Det är så enkelt. Inga nya adminmenysidor, inga klumpiga eller tillagda användargränssnitt. Bara dra och släpp på vyn för sidor eller inläggstyper.

Tillägget är ”medvetet om behörigheter” – endast användare med möjlighet att redigera andras sidor (redaktörer och administratörer) kommer att kunna ordna om innehåll.

Integrerad hjälp ingår: klicka bara på fliken ”Hjälp” högst upp till höger i vyn.

Observera att tillägget inte är kompatibelt med Internet Explorer 7 och tidigare, på grund av begränsningar i dessa webbläsare.

Bidragsgivare

Delta gärna i utvecklingen på GitHub.

Skärmdumpar

  • Sidan dras till dess nya position
  • Bearbetningsindikator

Installation

  1. Installera antingen via WordPress.org tilläggskatalog eller genom att ladda upp filerna till din server.
  2. Aktivera tillägget via menyn ”Tillägg” i WordPress.
  3. Kom igång med att sortera om ditt innehåll!

Vanliga frågor

Varför kan jag inte sortera om mina inlägg?

Generiska inlägg visas inte efter menysortering – de visas i kronologi. Du kan teoretiskt lägga till menysortering till inlägg i din kod (via ditt temas functions.php eller i ett tillägg) genom att använda:

add_post_type_support( 'post', 'page-attributes' );

Kan jag få min anpassade inläggstyp att dra fördel av detta tillägg?

Ja. När du registrerar inläggstypen inkludera funktionen page-attributes i argumentlistan suppors. Detta lägger till ett Manuell sortering-alternativ till filterlänkarna ovanför rullgardinsmenyerna. När du har sorterat efter ordning kan du dra och släppa innehållet.

'supports' => array( 'title', 'editor', 'page-attributes' ),

Alternativt, när du registrerar inläggstypen, ställ in hierarchical till true – hierarkiska inläggstyper sorteras naturligt efter menysortering.

Du kan också dra nytta av filtret simple_page_ordering_is_sortable, som skickar resultatet av standardkontrollen och inläggstypens namn, för att åsidosätta standardbeteendet.

Jag vill att min icke-hierarkiska inläggstyp ska vara sorterbar. Hjälp!

Se de två föregående svaren – lägg bara till page-attributes i listan över stödda funktioner för inläggstypen.

Jag ändrade ordning på mina inlägg, men ordningen ändrades inte på front-end av min webbplats!

Denna tillägg ändrar inte något beteende på frontend-delen, det ändrar helt enkelt menyordningen som lagras i WordPress.

Om du vill att en lista med sidor eller anpassade inläggstyper ska visas i den definierade ordningen måste du ändra inläggssökfrågan (query) orderby-parameter till menu_order (om den inte redan är det).

Jag ändrade ordning på mitt innehåll, det verkade fungera, men när jag uppdaterade återgick det till den gamla ordningen!

Detta innebär troligen att AJAX-begäran – koden på serversidan – misslyckades efter att du släppte innehållet i den nya positionen. Vissa webbhotell har en aggressiv tidsgräns (timeout) och begränsar AJAX-förfrågningar. Version 2.0 batchar dessa förfrågningar så att du kan försöka minska antalet objekt som uppdateras vid varje begäran med hjälp av ett filter i ditt temas functions.php eller ett anpassat tillägg:

add_filter( 'simple_page_ordering_limit', function($number) { return 5; } );

Där 5 är antalet artiklar som ska batchas på varje begäran (standardvärdet är 50). Observera att detta exempel använder PHP 5.3+ återanrops-funktioner, så om du fortfarande använder PHP 5.2 måste du lägga till ett traditionellt återanrop.

Vad hände med rullgardinsrutan som lät mig ändra antalet objekt på varje sida i administrations-delen?

Denna funktion är redan inbyggd i WordPress, men lite undangömd. Om du öppnar fliken ”Skärmalternativ” överst (i listan över inläggsobjekt) finns det ett fält där du kan ange antalet objekt som ska visas per sida. Jag bestämde mig för att det var en dålig praxis att duplicera detta.

Hur kan jag ändra sorterbara inläggstyper?

Inläggstyper kan inkluderas eller exkluderas genom att använda filtret simple_page_ordering_is_sortable.

Om du till exempel vill utesluta den anpassade inläggstypen excluded_post_type lägger du till följande kodsnutt i temats functions-fil eller i ett anpassat tillägg:

add_filter( 'simple_page_ordering_is_sortable', function( $sortable, $post_type ) {
    if ( 'excluded_post_type' === $post_type ) {
        return false;
    }
    return $sortable;
}, 10, 2 );

För att inkludera inläggstypen include_post_type, lägg till följande kodsnutt i temats functions.php-fil eller i ett anpassat tillägg:

add_filter( 'simple_page_ordering_is_sortable', function( $sortable, $post_type ) {
    if ( 'include_post_type' === $post_type ) {
        return true;
    }
    return $sortable;
}, 10, 2 );

Kan jag använda REST för att sortera inlägg?

Ja. Tillägget registrerar REST-ändpunkten simple-page-ordering/v1/page_ordering.

Recensioner

13 december 2023 1 svar
We'd struggled for a while implementing custom sort functionality for a long complex list for a client selling cameras ... until we found this plugin. All the issues we were having with a competitor's premium plugin were solved by switching to this plugin. The main thing was that we were able to manually sort on a custom post type whilst using custom filters. Works like a dream.
11 oktober 2023 2 svar
Super nice to be able to order pages in what is almost a grouping. Also works for Elementor Landing Pages [LP] CPT. Thanks for this free plugin and your time maintaining it. Please consider adding this functionality to Elementor template library and other CPT. And enabling the page order tab to be the default view to save time and not need to click and wait for it to load when I open the LP post type
3 september 2023 1 svar
This makes life so much easier - just drag pages and put them in the order yo want them. So much easier than editing and trying to remember what number comes next. Thanks so much for this.
9 maj 2023 1 svar
Simple Page Ordering is a fantastic plugin for WordPress that I highly recommend. One of the standout features of this plugin is its ease of use - it's incredibly intuitive and straightforward to navigate. The interface is simple and clean, making it easy to reorder pages and posts with just a few clicks. What's even more impressive is that Simple Page Ordering works seamlessly with other plugins, including the BetterDocs Plugin. I've had trouble with other page ordering plugins in the past, but this one has worked flawlessly. I think Simple Page Ordering is a must-have plugin for anyone looking to reorder their WordPress pages and posts quickly and easily.
6 maj 2023 1 svar
La utilizzo per tutti i siti che costruisco, è essenziale!
Läs alla 129 betyg

Bidragsgivare och utvecklare

”Simple Page Ordering” är programvara med öppen källkod. Följande personer har bidragit till detta tillägg.

Bidragande personer

”Simple Page Ordering” har översatts till 29 språk. Tack till översättarna för deras bidrag.

Översätt ”Simple Page Ordering” till ditt språk.

Intresserad av programutveckling?

Läs programkoden, kika på SVN-filförvaret eller prenumerera på utvecklarloggen via RSS.

Ändringslogg

2.6.3 – 2023-11-09

2.6.2 – 2023-11-09

  • Changed: Update the wp-compat-validation-tool composer package to version 0.3.1 which properly removes the .git directory (props @Sidsector9, @dkotter via #180).

2.6.1 – 2023-11-08

2.6.0 – 2023-10-25

2.5.1 – 2023-05-16

2.5.0 – 2023-04-18

Note that this release bumps the minimum required versions of PHP from 5.6 to 7.4 and WordPress from 3.8 to 5.7.

2.4.4 – 2023-01-10

2.4.3 – 2022-11-08

  • Changed: Allow hierarchical post types that don’t have page-attributes set to be sorted properly (props @dkotter, @peterwilsoncc via #108).
  • Security: Bump got from 10.7.0 to 11.8.5 (props @dependabot via #106).
  • Security: Bump @wordpress/env from 4.9.0 to 5.3.0 (props @dependabot via #106).
  • Security: Bump scss-tokenizer from 0.3.0 to 0.4.3 (props @dependabot via #107).
  • Security: Bump node-sass from 7.0.1 to 7.0.3 (props @dependabot via #107).

2.4.2 – 2022-09-28

2.4.1 – 2022-06-21

2.4.0 – 2022-04-28

2.3.4 – 2020-04-07

  • Changed: Avoid failed reordering introduced in v2.3.3 when handling a large number of non-hierarchical items (props @dinhtungdu).
  • Changed: Bump WordPress version support to 5.4 (props @tmoorewp).
  • Fixed: Ensure titles of reordered items appear in a human-readable way (props @dinhtungdu).

2.3.3 – 2020-03-04

2.3.2 – 2018-05-08

  • Tillagt: Tillåt avbrytande av dragfunktionen genom att trycka på escape-tangenten.
  • Fixed: Allow form input elements added to a row by plugins to be interacted with.

2.3.1 – 2018-04-13

  • Fixed: Prevent rows with hidden columns from jumping around while dragging.

2.3.0 – 2018-03-05

  • Tillagt: Använder WordPress-kärnans spinnerklass.
  • Added: Grunt-based build process with Sass.
  • Changed: Use WP_Query instead of get_posts() for better performance.
  • Changed: Remove bundled translations in favor of WordPress.org language packs.
  • Fixed: Avoid exceeding PHP’s max input variables, which could cause incorrectly assigned page order.
  • Fixed: Malformed URL that would take you to posts instead of pages.
  • Fixed: PHPDoc and coding standards to align with 10up’s Engineering Best Practices.

2.2.4 – 2015-02-08

  • Fixed: Redundant URL encoding when sorting in admin page list.

2.2.3 – 2014-09-27

  • Fixed: Ordering in WordPress 4.0 following core changes to ORDER BY in WP_Query.

2.2.2 – 2014-08-19

  • Added: German localization (props @glueckpress).
  • Fixed: Column widths no longer change when dragging a row (partial props @griffinjt).
  • Security: Closed obscure XSS vulnerability related to Sort by Order link (props @simon-waters).

2.2.1 – 2014-05-31

  • Added: Brazilian translation (props @felds).
  • Fixed: Bring back translations / text domain (yikes!).

2.2.0 – 2014-04-06

  • Changed: Look and feel to better match WordPress 3.8 admin redesign.
  • Changed: Improved awareness of and compatibility with Quick Edit (inline editor).
  • Fixed: Prevent collisions with themes and plugins bundling Simple Page Ordering.

2.1.2 – 2013-05-30

  • Fixed: Hierarchical custom post types without page-attributes was still broken – doh!
  • Fixed: Extreme edge case where post columns did not include the post title now supported.

2.1.1 – 2013-05-27

  • Fixed: custom post types with page-attributes or hierarchical properties, but not both, breaking ordering.

2.1.0 – 2013-05-19

  • Added: Awareness of custom user capabilities for post types, in addition to a filter (simple_page_ordering_edit_rights) for overriding reordering rights (previously used edit_others_pages globally).
  • Added: Awareness of custom post statuses (so they are not skipped during backend ordering operation).
  • Changed: UI refinements: Better ”spinner” positioning (and HiDPI), translucent row when moving, improved appearance of ”drop” placeholder, wait till row dragged by at least 5px to start sorting.
  • Changed: Major JavaScript refactoring and simplification (combined with new stylesheet) for better performance.

2.0.0 – 2012-11-12

  • Added: Drag pages into any part of the page hierarchy! No longer limited to same branch of tree!
  • Added: Big performance improvements under the hood: leaner queries, batched requests, less processing.
  • Added: New filters and hooks to extend / override default functionality.
  • Changed: Scales much more reliably in situations with very high page counts due to batching of requests.
  • Changed: Order of the first page is now set to ”1” instead of ”0”, so pages added after ordering are added at the top (instead of second).
  • Changed: Removed ”number of pages” drop down, which is repetitive of a field accessible under Screen Options.
  • Changed: Improved compatibility with newer versions of WordPress.

1.0.0 – 2011-07-04

  • Added: Support for ordering non-hierarchical post types that have ”page-attributes” support.
  • Added: New filter link for ”Sort by Order” to restore (hierarchical) or set (non-hierarchical, page attributes support) post list sort to menu order.
  • Changed: Users are now forced to wait for current sort operation to finish before they can sort another item.
  • Changed: Smarter about ”not sortable” view states.
  • Changed: Localization ready! Rough Spanish translation included.
  • Changed: Assorted other performance and code improvements.
  • Fixed: Unexpected page ordering results when pages have not been explictly ordered yet (sorts by menu_order, then title, not just menu_order).
  • Fixed: ”Per page” drop down filter selection not saving between page loads (was broken in 3.1).
  • Fixed: Items are always ordered with positive integers (potential negative sort orders had some performance benefits in last version, but sometimes caused issues).

0.9.6 – 2011-04-04

  • Fixed: for broken inline editing (quick edit) fields in Firefox.

0.9.5 – 2011-03-27

  • Changed: Smarter awareness of ”sorted” modes in WordPress 3.1 (can only use when sorted by menu order).
  • Changed: Smarter awareness of ”quick edit” mode (can’t drag).
  • Changed: Generally simplified / better organized code.

0.9.0 – 2010-12-29

  • Added: Further directions in the plug-in description (some users were confused about how to use it).
  • Added: Basic compatibility with 3.1 RC (prevent clashes with post list sorting).
  • Changed: ”Move” cursor only set if JavaScript enabled.
  • Fixed: Page count display always showing ”0” on non-hierarchical post types (Showing 1-X of X).
  • Fixed: Hidden menu order not updating after sort (causing Quick Edit to reset order when used right after sorting).

0.8.4 – 2010-08-24

  • Changed: Loosened constraints on drag and drop to ease dropping into top and bottom position.
  • Changed: Improved some terminology (with custom post types in mind).
  • Fixed: Row background staying ”white” after dropping into a new position.
  • Fixed: Double border on the bottom of the row while dragging.

0.8.2 – 2010-08-21

  • Changed: Simplified code – consolidated hooks.
  • Changed: Updated version requirements.