Single Quotes in .php file doesn’t load website

Your input line is enclosed in single quotes, so when PHP sees the single quote inside that string, it thinks you’re done with the string and jumping back into PHP. The way to fix this is to escape quotes inside the string so the single quoted words inside ga() change from ‘send’ to \’send\’.

Change max number of products on shop pages

You can add this code to your functions.php: /** * Change number of products that are displayed per page (shop page) */ add_filter( ‘loop_shop_per_page’, ‘new_loop_shop_per_page’, 20 ); function new_loop_shop_per_page( $products ) { // Return the number of products you wanna show per page. $products = 100; return $products; } Change the 100 for more if … Read more

How to re-arrange this hooked content?

To override action that use in plugin, use can wrap the remove_action code in template_redirect action to make sure your action will be excute later. For example add_action(‘template_redirect’, function() { // Remove the title. remove_action(‘sensei_course_content_inside_before’, array( ‘Sensei_Templates’, ‘the_title’ ) ,5, 1 ); // Add it again add_action(‘sensei_course_content_inside_before’, array( ‘Sensei_Templates’, ‘the_title’ ) ,15, 1 ); }, … Read more

How do I update every title of a certain category with a phrase

I would use a filter. Sometimes things change and strings have to be translated and so on: function my_custom_built_title( $title, $post_id ) { $post = get_post( $post_id ); if ( ‘product’ == $post->post_type ) { $terms = wp_get_post_terms( $post->ID, ‘product_cat’, [ ‘fields’ => ‘ids’ ] ); if ( in_array( ‘3439’, $terms ) ) { $title=”Custom … Read more

woocommerce_new_product action doesn’t fire

Try like function add_this_to_new_products( $new_status, $old_status, $post ) { global $post; if ( $post->post_type !== ‘product’ ) return; if ( ‘publish’ !== $new_status or ‘publish’ === $old_status ) return; add_post_meta( $post->ID, ‘total_amount’, ‘0’, true ); // This is the action to take } add_action( ‘transition_post_status’, ‘add_this_to_new_products’, 10, 3 );

Need Sub-category with main Category

maybe your children are empty, if so, they will not show up by default. you have to set the hide_empty argument to true. plus i cleaned your array a little, first you create one, and than in the next line you add more arguments. keep your code clean.. $optsetlect = (isset($_REQUEST[‘product_cat’]) && !empty($_REQUEST[‘product_cat’])) ? $_REQUEST[‘product_cat’] … Read more

Extend Woocommerce Widget Class – WC_Widget_Product_Categories

When calling parent::__construct() from WC_Widget_Product_Departments the constructor of WC_Widget_Product_Categories immediately overwrites the class properties (especially the widget_id), see here at GitHub. So you have to extend WC_Widget to create a new widget and then you can copy anything what you need in your widget from WC_Widget_Product_Categories to WC_Widget_Product_Departments.