Disable attachment pages

This code disables all attachment pages and redirects the user to the parent post or homepage depending on the post status. It uses the wp_safe_redirect() function to redirect the user and has an action hook of ‘template_redirect’ set with priority 1.

Completely disable comments

This code is used to disable comments and trackbacks from WordPress. It redirects any user trying to access the comments page, removes the comments metabox from the dashboard, disables support for comments and trackbacks in post types, and closes comments on the front-end. Additionally, it hides existing comments, removes the comments page from the menu, […]

woocommerce get first image gallery

This code retrieves the first image from a product image gallery, and then outputs the image URL. The product image gallery is retrieved from the post meta, and is then split into individual IDs, which are used to get the first image URL from the WordPress attachment library. Finally, the URL is outputted.

woocommerce get product image gallery

This code retrieves the product image gallery from the post meta, then separates the image IDs into an array. It then loops through the array to get the images’ URLs and displays them using the “img” HTML tag. The goal of this code is to display all images from the product image gallery.

woocommerce display payment methods

$gateway->id ) . ‘” style=”display:none;”>’ . $gateway->payment_fields() . ‘ ‘ : ” ) . ‘ ‘; } } This code checks if the WooCommerce plugin (WC) is available, then retrieves a list of available payment gateways and generates HTML elements for them. It also displays the gateway’s title and icon, and if the gateway has […]

woocommerce get all payment methods

This code iterates through the available payment gateways in WooCommerce and prints out the payment method ID for each one. This allows the website to show a list of available payment methods for customers when they are ready to check out.

woocommerce get available payment gateways

This code iterates through the available payment gateways for the WooCommerce plugin on WordPress and prints out their titles as HTML divs. It does this by using the WooCommerce payment gateways object to get all available payment gateways, and then looping through each gateway to get and print out the title.

woocommerce get payment methods

This code retrieves an array of payment gateways registered in WooCommerce and iterates through the array to echo the ID, title, icon, whether the gateway has additional fields required for checkout, and the order button text for each payment gateway.

woocommerce get payment gateway from order

This code obtains the payment gateway used for an order with the given order ID. The first line retrieves the order object, and the second line stores the payment method of the order in the $payment_gateway variable.

woocommerce get product category image by id

This code retrieves the image of a product category given its ID and displays it if it is found. The product category ID is retrieved as an integer from the $_GET array. Then, the thumbnail ID is obtained from the term meta of the product category with the same ID. Finally, the image is retrieved […]