View Categories

Products Per Page: Developer Hooks, Filters and Shortcodes Reference

The Number of Products per Page – Pagination Manager for WooCommerce plugin exposes a small set of hooks, filters and shortcodes so you can extend it in code. This reference lists every plugin-specific extension point in Products per Page version 2.5.4, verified against the source.

All settings referenced below live under WPFactory > Products per Page (also reachable at WooCommerce > Settings > Products per Page).

Action hooks #

These actions fire inside the plugin’s replacement pagination template (includes/templates/loop/pagination.php). They are also offered as selectable positions in the Position(s) setting, so you can render the selector around the catalog pagination without writing code.

Action Fires
alg_wc_products_per_page_before_pagination Inside the catalog pagination nav, before the page links
alg_wc_products_per_page_after_pagination Inside the catalog pagination nav, after the page links

Note that the plugin only overrides the pagination template when one of these two positions is selected. The template also runs the standard WooCommerce woocommerce_pagination_args filter.

Add your own markup after the pagination #

add_action( 'alg_wc_products_per_page_after_pagination', function () {
    echo '<p class="shop-hint">Use the selector above to change how many products load.</p>';
} );

Filters #

Filter Filtered value Arguments
alg_wc_products_per_page_select_options The list of selector options, as Title|Number lines separated by newlines $options
alg_wc_products_per_page_replace_pagination_template Whether the plugin replaces WooCommerce’s loop/pagination.php template (default true) $replace
alg_wc_products_per_page_settings Internal Pro gate for settings fields (see note below) $value, $type, $args

Define the selector options in code #

The alg_wc_products_per_page_select_options filter sets the option list. In Pro the saved settings value is used; you can override it for a specific context in code. Return a newline-separated string of Title|Number pairs, using -1 for all products.

add_filter( 'alg_wc_products_per_page_select_options', function ( $options ) {
    return implode( PHP_EOL, array( '12|12', '24|24', '48|48', 'All|-1' ) );
} );

Keep WooCommerce’s own pagination template #

If you use the Before pagination or After pagination positions but want to keep your theme’s pagination template, return false here. The selector actions will then not be injected.

add_filter( 'alg_wc_products_per_page_replace_pagination_template', '__return_false' );

Note on alg_wc_products_per_page_settings: this filter is how the plugin marks Pro-only settings fields as disabled or read-only. In the free build it returns an attribute array such as array( 'disabled' => 'disabled' ); in Pro it returns an empty string, removing the attribute. It is an internal licensing gate and is not intended for store customization.

The selector value is applied through core WooCommerce filters at the highest priority: loop_shop_per_page for the main catalog, and woocommerce_shortcode_products_query for the [products] shortcode (when Apply in WooCommerce shortcodes is enabled). The plugin also supports jet-woo-builder/shortcodes/jet-woo-products/query-args for JetWooBuilder grids. Scopes are evaluated with standard WordPress conditional tags such as is_shop() and is_product_category().

Shortcodes #

Shortcode Purpose
[alg_wc_products_per_page] Renders the selector form
[alg_wc_ppp_form] Alias of the above; identical output
[alg_wc_ppp_translate] Shows or hides text based on the active WPML or Polylang language

The selector shortcodes accept these attributes: template, select_class, select_style, before_html, after_html and radio_glue. Each falls back to its saved setting.

Template override #

The plugin’s pagination template can be overridden the standard WooCommerce way, by copying it to yourtheme/woocommerce/loop/pagination.php. Keep the two selector action calls if you want the Before and After pagination positions to keep working.

Meta and storage keys #

The shopper’s chosen value is stored under the key alg_wc_products_per_page in both the cookie and the WooCommerce session, and is read from the alg_wc_products_per_page request parameter on submit.

Deprecated placeholder #

The %select_form% template placeholder is deprecated. Use %dropdown% instead; both currently render the dropdown.

Need help? #

If you are extending Products per Page and a hook does not behave as expected, contact WPFactory support with the hook name and a short code sample.