The Custom Post Count plugin allows you to display the number of posts based on selected categories, tags, custom post types, and a specified date range. This plugin adds an admin page where you can configure your selections and view the resulting post count.
- Upload the
custom-post-count
directory to the/wp-content/plugins/
directory. - Activate the plugin through the 'Plugins' menu in WordPress.
- Navigate to the 'Post Count' page in the WordPress admin menu.
- Select the categories, enter tags (comma-separated), custom post types (comma-separated), and specify the date range.
- Click the 'Save Changes' button to save your selections.
- The post count based on your selections will be displayed on the same page.
- Select one or more categories.
- Enter tags as a comma-separated list.
- Enter custom post types as a comma-separated list.
- Specify a date range to filter posts.
- View the total number of posts that match your criteria.
Prevents direct access to the plugin file.
if (!defined('ABSPATH')) {
exit;
}
Adds a new menu item for the plugin in the WordPress admin.
add_action('admin_menu', 'cpc_add_admin_page');
Registers settings and fields for the plugin's admin page.
add_action('admin_init', 'cpc_register_settings');
Calculates and displays the post count based on selected criteria.
function cpc_display_post_count() {
// Implementation
}
add_action('admin_footer', 'cpc_display_post_count');
Adds the admin page to the WordPress menu.
Displays the settings form and post count results.
Registers the settings, sections, and fields for the plugin.
Sanitizes an array of inputs.
Callback function for the main section description.
Displays the categories as checkboxes.
Displays the tags input field.
Displays the custom post types input field.
Displays the 'Date From' input field.
Displays the 'Date To' input field.
Fetches and displays the post count based on selected criteria.
This plugin is open-source and available under the GPL-2.0+ license.