How To Check If Product Is On Sale By Product ID (WooCommerce)

To check if the product is on sale by using the product id: Get product object using product id => ($product = wc_get_product($id);) Get sale price of product => ($sale_price = $product->get_sale_price();) Lastly, get the price of product => ($price = $product->get_price();) Conclusion: get_price() method return the current active price. So, if the sale is […]

WordPress – Create Custom Post Type By Code

To create custom post type in WordPress there are two ways. One way is to do it by plugin and Second is to create custom post type by the code itself. Below is the code to create a custom post type [...]

WordPress – Order posts by custom order

To custom order WordPress posts or custom posts type add following code to your functions.php file in your theme folder: WordPress query to get posts ordered by menu order [...]

WordPress – Remove Contact Form 7 CSS and JavaScript If Page Does Not Have Contact Form

Contact form 7 includes its CSS and JavaScript files to all the pages even when there is no contact form on the page. This adds up more load to the page and includes unnecessary files which may conflict with other CSS and JS. It is a good practice to remove these files from all pages […]

How to add pagination in WordPress

There are generally two types of WordPress pagination you would see. One has the previous posts and the next posts link only, at the bottom of the page to navigate to next and previous lists of items or posts. Second shows all numbers of pages available to navigate to and the user can jump over […]