All New

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

Login

All New Login
's Avatar

Malin

Joined 2 years ago

Recently created
Least recently created
Recently updated
Least recently updated
All gists 102
Malin's Avatar

Malin / change-products-per-page.php

0 likes
0 forks
1 files
Last active 2 years ago
1 add_action( 'pre_get_posts', 'custom_woocommerce_products_per_page' );
2
3 function custom_woocommerce_products_per_page( $query ) {
4 // Check if we're on a WooCommerce shop page or product category or tag page and if it's the main query
5 if( !is_admin() && $query->is_main_query() && (is_woocommerce() || is_product_category() || is_product_tag()) ) {
6 $query->set( 'posts_per_page', 9 ); // Set the number of products per page to 12
7 }
8 }
9
Malin's Avatar

Malin / change-read-more-and-disable-button.php

0 likes
0 forks
1 files
Last active 2 years ago
1 // Change "Read More" text to "Out of Stock" for out-of-stock products
2 add_filter( 'woocommerce_product_add_to_cart_text', 'change_read_more_text_for_out_of_stock_products', 10, 2 );
3 function change_read_more_text_for_out_of_stock_products( $text, $product ) {
4 if ( !$product->is_in_stock() ) {
5 return 'No disponible'; // Change the text as needed
6 }
7 return $text;
8 }
9
10 // Remove the link of the "Add to Cart" / "Select options" / "Read More" button for out-of-stock products
Malin's Avatar

Malin / hide-0-stock-no-image.php

0 likes
0 forks
1 files
Last active 2 years ago
1 add_action('woocommerce_product_query', 'hide_products_without_image_and_zero_stock');
2
3 function hide_products_without_image_and_zero_stock($q) {
4 $meta_query = $q->get('meta_query');
5
6 // Condition to check for products with an image
7 $meta_query[] = array(
8 'key' => '_thumbnail_id',
9 'compare' => 'EXISTS' // Ensures the product has an associated image
10 );
Malin's Avatar

Malin / custom-checkout-fields.php

0 likes
0 forks
1 files
Last active 2 years ago
1 // Add a custom checkout fields for QRh, Tipo Cliente & NIF/CIF/NIE/DNI and save them to the database as META data
2
3 /**
4 * Add a 'Tipo cliente' dropdown field to the WooCommerce checkout page with specific options
5 */
6 add_filter('woocommerce_checkout_fields', 'custom_add_tipo_cliente_dropdown');
7 function custom_add_tipo_cliente_dropdown($fields) {
8 $fields['billing']['billing_tipo_cliente'] = array(
9 'type' => 'select',
10 'label' => __('Tipo cliente', 'woocommerce'),
Malin's Avatar

Malin / custom-login-qrh.php

0 likes
0 forks
1 files
Last active 2 years ago
1 // custom login styles and logo for QRh
2
3 function custom_login_styles() {
4 $logo_url = 'https://qrh.app/wp-content/uploads/2021/09/QR-h-rojoAsset-7-300x243.png';
5 ?>
6 <style type="text/css">
7 /* Change login logo */
8 body.login div#login h1 a {
9 background-image: url(<?php echo $logo_url; ?>);
10 padding-bottom: 30px;
Malin's Avatar

Malin / redirect-logout-to-home.php

0 likes
0 forks
1 files
Last active 2 years ago
1 // redirect Wordpress logout to home
2
3 add_action('wp_logout','auto_redirect_after_logout');
4 function auto_redirect_after_logout(){
5 wp_redirect(home_url());
6 exit();
7 }
Malin's Avatar

Malin / move-out-of-stock.php

0 likes
0 forks
1 files
Last active 2 years ago
1 // move out of stock products to end of loop in WooCommerce Archives
2
3 add_action( 'woocommerce_product_query', 'custom_woocommerce_product_query' );
4 function custom_woocommerce_product_query( $q ) {
5 // Get any existing meta query from the query
6 $meta_query = $q->get('meta_query');
7
8 // Add our condition
9 $stock_status_meta_query = array(
10 'relation' => 'OR',
Malin's Avatar

Malin / link-logo-to-homepage.php

0 likes
0 forks
1 files
Last active 2 years ago
1 // link Wordpress login form logo to homepage and also logo hover text
2
3 // Change the login page logo link to your homepage
4 function my_custom_login_url() {
5 return home_url();
6 }
7 add_filter('login_headerurl', 'my_custom_login_url');
8
9 // Change the login page logo hover text
10 function my_custom_login_title() {
Malin's Avatar

Malin / custom-rewrite-qrh.php

0 likes
0 forks
1 files
Last active 2 years ago
1 // force URL rewrite for QRh
2 function custom_rewrite_rule() {
3 // Adding a rewrite rule that maps the new URL to the internal query for product-category/outlet.
4 add_rewrite_rule('^tienda/outlet/?$', 'index.php?product_cat=outlet', 'top');
5 }
6 add_action('init', 'custom_rewrite_rule');
7
8 function custom_rewrite_tag() {
9 // Adding the custom query var to ensure WordPress recognizes it.
10 add_rewrite_tag('%product_cat%', '([^&]+)');
Malin's Avatar

Malin / deactivate-google-feed.php

0 likes
0 forks
1 files
Last active 2 years ago
1 // custom QRh Feed check - not working correctly
2 add_action('woocommerce_product_options_inventory_product_data', 'add_google_feed_checkbox');
3
4 function add_google_feed_checkbox() {
5 global $post;
6
7 // Get the current value of the '_google_feed_include' meta key.
8 $google_feed_include = get_post_meta($post->ID, '_google_feed_include', true);
9
10 // Convert the meta value to a boolean.
Newer Older

Powered by Opengist ⋅ Load: 635ms⋅

English
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文