ReOrder Posts within Categories

Beskrivning

UPGRADE NOTE if you are upgrading from v1.x, your old ranking data remains unaffected in the custom table used by the v1.x plugin. However, in v2.x all the ranking is now stored as post meta. While upgrading, some users have complained of missing posts/ lost rankings. If this is the case, you can reset your order for given term using the reset checkbox/button provided in the admin page (see screenshot #4). It will reload the ranking from the v1.x custom table.

If your term was not sorted in the v1.x table or you are upgrading from v2.0.x or v2.1.x, then the reset button will reload the post order as per the default WP post table listing, which can be changed using the filtrs provided (see FAQ #7).

ReOrder Post Within Categories is used to sort posts (and custom post type) in any custom order by drag & drop interface.
It works with a selected category, each category can have different order of same post.

New enhanced version 2.0 with grid-layout and multi-drag interface to ease sorting of large list of posts. Makes use of SortableJS plugin. If you are using this plugin for a commercial website, please consider making a donation to the authors of the SortableJS plugin to continue its development.

Tack till

Nikita Spivak for the Russian translation.
Tor-Bjorn Fjellner for the swedish translation and i18n clean-up.
alekseo for support for the plugin.
Andrei Negrea for post delete bug fix.

Skärmdumpar

  • Plugin page settings, if you uninstall this plugin for good, delete all data using this settings page first before deactivating the plugin.
  • Re-order your post through a drag & drop grid-layout interface with multi-select capabilities. For large sets of posts, a range slider will appear allowing you to view your posts in sub-sets by moving the slider range accordingly and sorting posts in smaller more manageable groups. You can also multi-select the posts and enter a rank value to which you want to send those selected posts too. For example, if you are sorting posts between the ranks fo 100 and 150 and you want to send 3 posts to the beginning of the order, simply select them and enter 1 in the rank input field and press enter. A rest button is introduced in v2.1 so an order can be reset. Using the filters described in faq #7 it is possible to reset the default ranking to various initial ordered lists.
  • v2.1 introduced a reset button on the amdin reorder page. The checkbox enables the button which you can use to reset your posts ranking order for this term. This in conjunction with the intial order filters (see FAQ 7) allows you to set a chronological or an alphabetical ranking for the initial order.
  • the reset checkbox will enable the reset button. If you upgraded from v1.x and you have not deteleted the custom table used in the previous versions, the reset button will reload your previously stored ranking for ther term if it exists in the table. Otherwise the default post table ranking will be loaded which can be modified using the filters provided (see FAQ #7 for more info).

Installation

  1. Upload the ’reorder-posts-within-categories’ folder to the ’/wp-content/plugins/’ directory
  2. Activate the plugin through the ’Plugins’ menu in WordPress
  3. Go to the settings page to activate sorting for each categories you choose.

Vanliga frågor

1.Modify the reorder category query

A filter allows you to hook into the query of the posts before your reorder them in the dashboard. This is useful is you want to order parent terms posts and not children. WP post category query by default include post from children terms, which will show up in the order list. So by excluding them you are able to order only the posts of parent terms,

add_filter('reorder_post_within_category_query_args', 'exclude_children');
function exclude_children($args) {
    $args['tax_query'][0]['include_children']=false;
    return $args;
}
2.I want to order posts in non-hierarchical taxonomies (tags)

Som standard låter tillägget dig sordera inlägg endast inom hierarkiska taxonomier (kategorier). Detta görs för att undvika okontrollerad sorteringsordning då sortering enligt både etiketter och kategorier kan leda till att användare försöker att sortera ett inlägg enligt båda ordningarna, vilket skulle kunna leda till situationer som tilläggets upphovsman inte testat. Därför bör du vara försiktig om du aktiverar denna funktion i din functions.php,

add_filter('reorder_post_within_categories_and_tags', '__return__true');

Ha i åtanke att du nu kommer att betrakta Sidor som en inläggstyp du kan sortera om, genom att välja inläggstyper som inte har några kategorier kopplade till dem.

3.I want limit/enable roles that can re-order posts

Från version 1.3.0 har ett nytt filter lagts till som ger dig just denna möjlighet. Se till att de returnerar en giltig behörighet,

add_filter('reorder_post_within_categories_capability', 'enable_editors', 10,2);
function enable_editors($capability, $post_type){
    //you can filter based on the post type
    if('my-users-posts' == $post_type){
        $capability = 'publish_posts'; //Author role.
    }
    return $capability;
}

om en okänd behörighet returneras kommer tillägget att använda standardvärdet ’manage_categories’, vilket är en behörighet som en administratör har.

4.I am uninstalling this plugin, how do I removed the custom table data ?

Nu kan du flagga att den anpassade sql-tabellen ska tas bort när tillägget inaktiveras i din adminpanel med hjälp av följande filter,
add_filter(’reorder_post_within_categories_delete_custom_table’, ’__return__true’)
Observera att detta filter körs när du inaktiverar tillägget i adminpanelen. Du behöver därför se till att tillägget är aktiverat när du ställer in filtret.

5.Can newly published posts be ranked first rather than last?

Yes, as of v2.0 newly published posts can be ranked first instead of last by default using the following filter,

add-filter('reorder_post_within_categories_new_post_first', 'rank_new_posts', 10, 3);
function rank_new_posts($is_first, $post, $term){
    $is_first = true;
    //you can filter by taxonomy term, or other post parameters.
    //WP_Post $post;
    //WP_Term $term.
    return $is_first;
}

NOTE: the post-type must already have a manual ranking for that category term for this hook to fire. TO ensure this, go to the post ReOrder admin page, select the category term and manually order a couple of post, this is enough to ensure this hook fires. Even if you have the manual ranking radio-toggle to ’No’, this hook will still fire.

6. Is it possible to customise the text on the sortable cards?

Yes. On v2+ of this plugin, the sortable cards are now displaying the thumbnail of each posts along with the title. The title text can be changed or added to in case you require additional meta fields to be displayed to help you manually rank your posts. To achieve this, hook the following filter,

add_filter ('reorder_posts_within_category_card_text', 'custom_card_text', 10,3 );
function custom_card_text($text, $post,$term_id){
  //the $text is set to the title fo the post by default.
  //$post is the WP_Post object.
  //$term_id is the taxonomy term being sorted.
  $text = '<div>'.$text.'</div><div>'.get_post_meta($post->ID, 'custom-field', true).'</div>';
  return $text;
}
7. The initial order of post is chronological, can it be changed?

Yes, by default the first time you manually sort your posts, they will be presented in the same order as your post table, namely by post data. There are 3 possible alternative default order you can set,
1.reverse chronological by hooking this filter,

add_filter('reorder_posts_within_category_initial_order', 'reverse_order', 10, 3);
function reverse_order($reverse, $post_type, $term_id){
  //$reverse is a boolean flag.
  //$post_type for the current posts being ranked.
  //$term_id of the taxonomy term for which the posts are being ranked.
  return true;
}
  1. by alphabetical title order, using the following hook,

    add_filter(’reorder_posts_within_category_initial_orderby’, ’chronological_or_alphabetical_order’, 10, 3);
    function chronological_or_alphabetical_order($is_alpha, $post_type, $term_id){
    //$is_alpha is a boolean flag set to false by default.
    //$post_type for the current posts being ranked.
    //$term_id of the taxonomy term for which the posts are being ranked.
    return true;
    }

  2. or by reverse alphabetical title order, using both of the above hooks,

    add_filter(’reorder_posts_within_category_initial_order’, ’reverse_order’, 10, 3);
    function reverse_order($reverse, $post_type, $term_id){
    //$reverse is a boolean flag.
    //$post_type for the current posts being ranked.
    //$term_id of the taxonomy term for which the posts are being ranked.
    return true;
    }
    add_filter(’reorder_posts_within_category_initial_orderby’, ’chronological_or_alphabetical_order’, 10, 3);
    function chronological_or_alphabetical_order($is_alpha, $post_type, $term_id){
    //$is_alpha is a boolean flag set to false by default.
    //$post_type for the current posts being ranked.
    //$term_id of the taxonomy term for which the posts are being ranked.
    return true;
    }

NOTE: in all 3 cases, you may use the reset button (see screenshot #3) on the reorder admin page to get the filters to change the order.

Recensioner

12 mars, 2019
Using the Avada theme, I tried to use it to reorganize my Portfolio posts. It was clunky on the reorder page in that, if I added a post to a category, I had to completely leave this page and come back in to see the new post in the reorder list (reloading the page didn't work and there's no save/update button to force a reload either). The real issue is though when using the Portfolio Fusion element on a page that displays more than one category, it worked for the first category displayed but destroyed the formatting in weird ways of the other category. I spent about an hour playing with it trying to get it to work before giving up as the results were constantly inconsistent. Perhaps it works well with other themes but not good for my purposes.
9 mars, 2018
I had a problem with my cache. Sorry to complain before. It's ok.
11 januari, 2018
I am so happy right now. This plugin gave me exactly what I was hoping, simple and does what it says it will do. Cheers to the developer!
Läs alla 40 betyg

Bidragsgivare och utvecklare

”ReOrder Posts within Categories” är programvara med öppen källkod. Följande personer har bidragit till detta tillägg.

Bidragande personer

”ReOrder Posts within Categories” har översatts till 7 språk. Tack till översättarna för deras bidrag.

Översätt ”ReOrder Posts within Categories” till ditt språk.

Intresserad av programutveckling?

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

Ändringslogg

2.2.0

  • removed delete_before_post.
  • reset post rank from v1.x table in admin page.

2.1.4

  • fix sql order by bug in admin order page.

2.1.3

  • fix bug on save_post.

2.1.2

  • fix multisite bug.

2.1.1

  • fix slider post loading.
  • max posts loaded to form square grid.

2.1.0

  • deprecated filter ’reorder_post_within_category_taxonomy_term_query_args’.
  • improved helper text on reorder pages.
  • added a reset button on order page.

2.0.1

  • js bug fix preventing proper saving of orders.

2.0.0

  • complete re-write of the plugin file structure.
  • removal of custom DB table, post rank is now saved as a postmeta key.
  • addition of a new filter ’reorder_post_within_categories_new_post_first’ to allow new posts to be ranked first instead of last by default.
  • proper handling of post_type for order ranking.
  • ability to reset/delete data from settings page.
  • added filter ’reorder_posts_within_category_card_text’.
  • added filter ’reorder_posts_within_category_initial_orderby’.
  • added filter ’reorder_posts_within_category_initial_order’.
  • using sortableJS plugin for Grid layout using multi-grid sorting for large lists.
  • addition of thumbnails on sortable cards for better visual representation of posts.

1.8.1

  • Rättelser av engelska

1.8.0

  • I18N: Ändrat språket i översättningsbara strängar till en_US. Kommentarer i koden är fortfarande på franska.

1.7.0

  • lagt till länk till inlägg i adminpanelens sorteringslista.

1.6.0

  • lagt till filter för termdatabasfråga
    ’reorder_post_within_category_taxonomy_term_query_args’

1.5.0

  • rättat fel kring behörigheter.
  • lagt till filter för att ta bort en anpassade SQL-tabell i samband med avinstallation.

1.4.1

  • korrigerat text-domain för att hantera tillägget via translate.wordpress.org.

1.4.0

  • lagt till rysk version.
    =1.3.0=
  • lagt till filter för ändrad behörighet för åtkomst till undermenyn för sortering av inlägg.
    =1.2.3=
  • felrättning

1.2.2

  • förbättrat hur man väljer anpassade inläggstyper i inställningarna
  • lagt till filter ’reorder_post_within_categories_and_tags’

1.2.1

  • added filter ’reorder_post_within_category_query_args’

1.2

  • cleaned up, included better messages to ensure settings are saved after activation, else order menu is not shown
  • fixed a small bug

1.1.7

  • Bug fix to allow plugin to work with WP multisite network installation.
  • enable editor role access to re-order menu
  • fixed some languages translation issues

1.1.6

  • Important bug fix (See https://wordpress.org/support/topic/updating-a-post-removes-it-from-the-custom-order). Thanks to Faison for this fix

1.1.5

  • Add DE_de language

1.1.4

  • Correct minor bug

1.1.3

  • Add spanish translations. Special thanks to David Bravo for this !

1.1.2

  • Add a plugin URI

1.1.1

  • Bug Correction when a post is saving

1.1

  • Change version number

1.0

  • Minor Correction

0.1

  • First commit; Initial version