Beskrivning
Tired of uncategorized posts? Use this simple plugin to require users to choose a post category before updating or publishing a post. By default this only applies to normal posts. If you wish to require a category/taxonomy for a custom post type see the FAQ for filter hook usage examples.
Översättare
- Franska (fr_FR) – Dominique V.
- Spanska (es_ES) – Andrew Kurtis – WebHostingHub
- Polska (pl_PL) – Michał Papliński
- Finska (fi) – Sanapaino
If you have created your own language pack, or have an update of an existing one, you can send the PO and MO files to me so that I can bundle it into the plugin. Download the latest POT file.
Skärmdumpar
Installation
From your WordPress dashboard
- Besök ”Tillägg och lägg till nytt”
- Search for ’require post category’ and click the Install button
- Activate Require Post Category from your Plugins page.
Från WordPress.org
- Ladda ner ”Require Post Category”.
- Upload the ’require-post-category’ directory to your ’/wp-content/plugins/’ directory, using your favorite method (ftp, sftp, scp, etc…)
- Activate Require Post Category from your Plugins page.
Vanliga frågor
-
Finns det några inställningar jag kan justera?
-
Nej, bara att installera och aktivera, det är allt!
-
Hur använder jag detta för anpassade inläggstyper och/eller anpassade taxonomier?
-
Use the
rpc_post_types
filter hook in your theme’sfunctions.php
or a must-use plugin.Exempel på användning:
function custom_rpc_post_types( $post_types ) { // Add a key to the $post_types array for each post type and list the slugs of the taxonomies you wish to require // Simplest usage $post_types['book'] = array( 'genre' ); // Multiple taxonomies $post_types['recipe'] = array( 'cookbook_category', 'geographic_origin', 'flavor_tags' ); // Set your own alert message for each taxonomy, or let the plugin generate the alert message $post_types['inventory'] = array( // Let the plugin generate a relevant alert message 'manufacturer', // Or specify a custom alert message 'inventory_category' => array( 'message' => "Please choose a category for this fine inventory item." ) ); // Always return $post_types after your modifications return $post_types; } add_filter( 'rpc_post_types', 'custom_rpc_post_types' );
The default
$post_types
contains the following:$post_types['post'] = array( 'category' => array( 'message' => 'Please select a category before publishing this post.' ) );
This maintains the plugin’s original functionality. However, you can remove this functionality with
unset($post_types['post']);
or by redefining$post_types
in your hook function. -
You’ve added code to require a custom taxonomy but can’t get it to work in the Gutenberg editor?
-
One reason may be that your custom taxonomy does not have the
show_in_rest
argument enabled. Without it enabled the Gutenberg editor cannot access it. -
Har du en fråga som inte är listad här?
-
Visit this plugin’s WordPress support forum at https://wordpress.org/support/plugin/require-post-category
Recensioner
Bidragsgivare och utvecklare
”Require Post Category” är programvara med öppen källkod. Följande personer har bidragit till detta tillägg.
Bidragande personer”Require Post Category” har översatts till 1 språk. Tack till översättarna för deras bidrag.
Översätt ”Require Post Category” till ditt språk.
Intresserad av programutveckling?
Läs programkoden, kika på SVN-filförvaret eller prenumerera på utvecklarloggen via RSS.
Ändringslogg
2.1
- Updated for WordPress 5.5
- FIXED: Deprecated function notice listed in jQuery Migrate Helper plugin (Classic Editor)
- FIXED: Submitting post form by pressing enter in the title field would bypass checks (Classic Editor)
2.0.3
- Added Finnish (fi) translation by Sanapaino
2.0.2
- FIXED: Custom taxonomy
rest_base
value of boolean false was not being properly handled.
2.0.1
- Repaired translation files.
2.0
- Rewritten for the new Gutenberg editor (first introduced in WordPress 5.0)
1.1
- NEW: Added a filter hook and related code to allow developers to easily add support for custom post types and custom taxonomies
- Updated to meet WordPress PHP coding standards
1.0.7
- Moved JavaScript to separate file and updated to use
wp_enqueue_script
andwp_localize_script
1.0.6
- Added French (fr_FR) translation by Dominique V.
1.0.5
- Added Polish (pl_PL) translation by Michał P.
1.0.4
- Added Spanish (es_ES) translation by Andrew K.
1.0.3
- Added i18n support
1.0.2
- Updated for WordPress 3.6
1.0.1
- FIXED: Disabled script when adding/editing pages
1.0
- First stable release