Support » Plugin: WooCommerce Products Per Page » Shortcode

  • Plugin Author Jeroen Sormani

    (@sormano)


    Once in a while I get the question for a shortcode for the dropdown. I created a small code snippet that adds this shortcode, but because there are mixed results expected with different themes and locations I cannot provide any support on this shortcode (hence why it isn’t in the plugin itself).

    It is not expected to work on a page where you’re showing the products through a WC shortcode, though I must admit I haven’t tested it either 😉

    
    function custom_wppp_shortcode() {
    	if ( method_exists( Woocommerce_Products_Per_Page()->front_end, 'products_per_page_dropdown' ) ) {
    		Woocommerce_Products_Per_Page()->front_end->products_per_page_dropdown();
    	}
    }
    add_shortcode( 'wppp', 'custom_wppp_shortcode' );
    
Viewing 1 replies (of 1 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    I found a mistake with the above code snippet, not doing a proper check if the WPPP plugin is active, and giving an error when it wasn’t.

    With this code snippet it should work properly, and not give the error when the plugin is not active.

    
    function custom_wppp_shortcode() {
    	if ( function_exists( 'Woocommerce_Products_Per_Page' ) ) {
    		Woocommerce_Products_Per_Page()->front_end->products_per_page_dropdown();
    	}
    }
    add_shortcode( 'wppp', 'custom_wppp_shortcode' );
    
Viewing 1 replies (of 1 total)
  • The topic ‘Shortcode’ is closed to new replies.