Removing and tags in WordPress posts

This happens because of WordPress’s wpautop. Simply add below line of code in your theme’s functions.php file remove_filter( ‘the_content’, ‘wpautop’ ); remove_filter( ‘the_excerpt’, ‘wpautop’ ); For more information: http://codex.wordpress.org/Function_Reference/wpautop

How to display Woocommerce product price by ID number on a custom page?

If you have the product’s ID you can use that to create a product object: $_product = wc_get_product( $product_id ); Then from the object you can run any of WooCommerce’s product methods. $_product->get_regular_price(); $_product->get_sale_price(); $_product->get_price(); Update Please review the Codex article on how to write your own shortcode. Integrating the WooCommerce product data might look … Read more

Fatal error: Uncaught ReflectionException: Method get_site_editor_type does not exist

Change the code $reflection = new \ReflectionClass( $class_name ); //45 line $method = $reflection->getMethod( ‘get_site_editor_type’ ); // It’s own method, use it. if ( $class_name === $method->class ) { return static::get_site_editor_type(); } By if (method_exists($class_name, “get_site_editor_type”)) { $reflection = new \ReflectionClass( $class_name ); $method = $reflection->getMethod( ‘get_site_editor_type’ ); // It’s own method, use it. if … Read more

Remove category & tag base from WordPress url – without a plugin

If you want to remove /category/ from the url, follow these two steps: Go to Settings >> Permalinks and select Custom and enter: /%category%/%postname%/ Next set your Category Base to . Save it and you’ll see your URL changed to this format: http://yourblog.com/quotes/ (Source: http://premium.wpmudev.org/blog/daily-tip-quick-trick-to-remove-category-from-wordpress-url/)

WordPress: save `get_template_part()` to variable

This isn’t what get_template_part was for, get_template_part essentially behaves like PHP’s require function. Justin Tadlock writes a lot more about this here and also talks about a WordPress function that might be more useful to you – locate_template. Alternatively, if you did want to hack this functionality using get_template_part, you could use template buffering: function … Read more

Using WPDB in standalone script?

The best(fastest and safest) way to load only load the core functionality of WordPress is to use the SHORTINIT flag like this: define( ‘SHORTINIT’, true ); require( ‘/path/to/wp-load.php’ ); //Here you can use WordPress core features, for example the $WPDB object For more information about this and see what is loaded, is to check the … Read more