• Hi I’m trying to make a function to add a woocommerce sort by drop down appear on a specific shop page (the main shop page only (id=655)).

    function addDropDown()
    	{
    
    		global $wp_query;
    		$pageid = $post->ID;
    
    		if($pageid=655)
    		{
    			add_action( 'woocommerce_before_main_content', 'woocommerce_catalog_ordering', 20 );
    		}
    	}
    	add_action('init', 'removeDropDown');

    I use add_action( 'woocommerce_before_main_content', 'woocommerce_catalog_ordering', 20 ); to add the drop down menu to the shop pages. However it appears on the shop page and the single product page.

    Even if i change if($pageid=655) to if($pageid=6) the drop down appears on both the shop page and single product page!

    Help please!

  • The topic ‘Help with php function’ is closed to new replies.