• Skip to main content
  • Skip to primary sidebar

WordPress, Genesis Framework and Storefront customization tutorials

  • Archive
    • Free
    • Premium
  • Blog
  • About
  • Contact
  • Newsletter
  • Login
Home » Free » Page 10

Free

Change “Related products” text in WooCommerce

// =========================================================================
// CHANGE RELATED PRODUCTS TEXT TO YOU MAY ALSO LIKE TEXT
// =========================================================================  
function change_you_may_also_like( $translated ) {
   $translated = str_replace( 'Related products', 'You may also like...', $translated );
   return $translated;
}
add_filter( 'gettext', 'change_you_may_also_like' );

Filed Under: Free Tagged With: WooCommerce

How to change “On Sale” text in WooCommerce

// =========================================================================
// CHANGE ON SALE TEXT
// =========================================================================
function woocommerce_custom_sale_text($text, $post, $_product){
    return '<span class="onsale">Special offer</span>';
}
add_filter('woocommerce_sale_flash', 'woocommerce_custom_sale_text', 10, 3);

Filed Under: Free Tagged With: WooCommerce

How to add sticky footer to Genesis with flexbox

/* Sticky Footer */

.site-container {
     display: -ms-flexbox;
     display:-webkit-flex;
     display:-webkit-box;
     display:flex;
     -ms-flex-direction:column;
     -webkit-flex-direction:column;
     -webkit-box-orient:vertical;
     -webkit-box-direction:normal;
     flex-direction:column;
     min-height:100vh;
}

.site-inner {
     -ms-flex:1;
     -webkit-flex:1;
     -webkit-box-flex:1;
     flex:1;
     width: 100%;
     padding: 20px 0;
     word-wrap: break-word;
}

Filed Under: Free Tagged With: Genesis

How to change Additional information text based on product ID in WooCommerce

// =========================================================================
// CHANGE ADDITIONAL INFORMATION TEXT
// =========================================================================
/* @return string Modified value for product's "Additional information" text. */
function wpdd_change_additional_information_heading() {
    global $product;
    if( $product->id == 2028 ){
	   return __( 'Further information', 'mytextdomain' );
    }elseif($product->id == 2027){
	   return __( 'En savoir plus', 'mytextdomain' );
    }else{
        return __( 'További információk', 'woocommerce' );
    }
}
add_filter( 'woocommerce_product_additional_information_heading', 'wpdd_change_additional_information_heading' );

Filed Under: Free Tagged With: WooCommerce

Change “Add to cart” button text on specific pages in Woo

// =========================================================================
// CHANGE ADD TO CART BUTTON TEXT ON SPECIFIC PAGES
// =========================================================================
function translate_add_to_cart() {
    global $product;
    if( $product->id == 2028 ){
        return __( 'Add to basket', 'woocommerce' );
    } elseif($product->id == 2027){
        return __( 'Buy now', 'woocommerce' );
        }
    else{
        return __( 'Add to cart', 'woocommerce' );
    }
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'translate_add_to_cart', 10, 3 );

Filed Under: Free Tagged With: WooCommerce

Set user capabilities to edit only specific pages in WordPress

1) Install the PublishPress Capabilities plugin

PublishPress Capabilities

2) Create a new user with the role editor

create a new user

3) Uncheck the checkboxes

4) Assign the specific post to the guest user

5) Log in into the guest account with the editor role

As You can see there’s no other pages to edit except this one

 

Filed Under: Free Tagged With: WordPress

User specific CSS for WordPress admin

Add this snippet to functions.php

function add_css_to_guest_user() {
    $guest_user = wp_get_current_user();

    if($guest_user && isset($guest_user->user_login) && 'guest' == $guest_user->user_login) {
        wp_enqueue_style( 'guest_admin_css', get_stylesheet_directory_uri() . '/css/wpadmin-guest.css' );
    }
}
add_action('admin_print_styles', 'add_css_to_guest_user' );

2) CSS

If You want to hide the CF7 menu item on guest user’s WordPress admin use this CSS

#toplevel_page_wpcf7 {
	display: none;
}

Filed Under: Free Tagged With: WordPress

How to add custom menu item to the WordPress nav menu

The content between the li tags could be anything You want!

For example shortcode for language switcher, social icons or custom text.

// =========================================================================
// ADD CUSTOM MENU ITEM TO THE WORDPRESS NAV MENU
// =========================================================================
function add_custom_menu_item ($items, $args) {
    $items .= '<li id="menu-item-5000" class="menu-item menu-item-type-post_type menu-item-object-page last">';
        $items .= 'Last Menu Item';
    $items .= '</li>';
    return $items;
}
add_filter( 'wp_nav_menu_items', 'add_custom_menu_item', 10, 2 );

Filed Under: Free Tagged With: WordPress

Remove WooCommerce Image Zoom Support in Single Product

// =========================================================================
// REMOVE WOOCOMMERCE IMAGE ZOOM SUPPORT ON SINGLE PRODUCT
// =========================================================================
function remove_image_zoom_support() {
    remove_theme_support( 'wc-product-gallery-zoom' );
}
add_action( 'wp', 'remove_image_zoom_support', 100 );

Filed Under: Free Tagged With: Storefront

Change Storefront footer credit text

Remove “Built with Storefront & WooCommerce” text

Create a footer.php file in your child theme and include it in to the storefront_footer hook

Footer copyright

Custom footer with SVG Social icons

SCSS

Filed Under: Free Tagged With: Storefront

How to create custom breadcrumbs in WordPress

Filed Under: Free Tagged With: WordPress

Remove header cart in Storefront

// =========================================================================
// REMOVE HEADER CART
// =============================================================
function remove_sf_actions() {

	remove_action( 'storefront_header', 'storefront_header_cart', 60 );

}
add_action( 'init', 'remove_sf_actions' );

Filed Under: Free Tagged With: Storefront

How to list WooCommerce product categories

// =========================================================================
// DISPLAY PRODUCT CATEGORIES
// =========================================================================
function woocommerce_product_category( $args = array() ) {
    $woocommerce_category_id = get_queried_object_id();
  $args = array(
      'parent' => $woocommerce_category_id
  );
  $terms = get_terms( 'product_cat', $args );
  if ( $terms ) {
      echo '<ul id="myFilter" class="woocommerce-categories">';
      foreach ( $terms as $term ) {
          echo '<li class="woocommerce-product-category-page">';
              echo '<a href="' .  esc_url( get_term_link( $term ) ) . '" class="btn-filter ' . $term->slug . '">';
                echo $term->name;
              echo '</a>';
          echo '</li>';
      }
      echo '</ul>';
  }
}
add_action( 'woocommerce_archive_description', 'woocommerce_product_category', 10 );

Filed Under: Free Tagged With: WooCommerce

Create a text field in the Customizer and show it in the front end

1) Add this to your functinos.php


// =========================================================================
// REGISTER CUSTOMIZER - PANEL, SECTION, SETTINGS AND CONTROL
// =========================================================================
function theme_name_register_theme_customizer( $wp_customize ) {
    // Create custom panel.
    $wp_customize->add_panel( 'text_blocks', array(
        'priority'       => 10,
        'theme_supports' => '',
        'title'          => __( 'Text Blocks', 'theme_name' ),
        'description'    => __( 'Set editable text for certain content.', 'theme_name' ),
    ) );
    // Add section.
    $wp_customize->add_section( 'custom_title_text' , array(
        'title'    => __('Custom Text','theme-name'),
        'panel'    => 'text_blocks',
        'priority' => 10
    ) );
    // Add setting
    $wp_customize->add_setting( 'title_text_block', array(
         'default'           => __( 'Default text', 'theme-name' ),
         'sanitize_callback' => 'sanitize_text'
    ) );
    // Add control
    $wp_customize->add_control( new WP_Customize_Control(
        $wp_customize,
        'custom_title_text',
            array(
                'label'    => __( 'Custom Text', 'theme_name' ),
                'section'  => 'custom_title_text',
                'settings' => 'title_text_block',
                'type'     => 'text'
            )
        )
    );
 
    // Sanitize text
    function sanitize_text( $text ) {
        return sanitize_text_field( $text );
    }
}
add_action( 'customize_register', 'theme_name_register_theme_customizer' );

2) Show in the Front End with a hook

function add_custom_field(){
    echo get_theme_mod( 'title_text_block');
}
add_action('genesis_site_description', 'add_custom_field');

In this case I’ve placed the custom text in the site-description, but You can put it anywhere You want using the Genesis Visual Hook Guide.

Add custom text via customizer

Filed Under: Free Tagged With: PHP

How to add PDF upload option to WordPress customizer?

1) Add this snippet to functions.php

// =========================================================================
// CUSTOMIZER PDF UPLOAD
// =========================================================================
function pdf_customize_register( $wp_customize ) {
 
    // Add Settings
    $wp_customize->add_setting('customizer_setting_pdf', array(
        'transport'         => 'refresh'
    ));
 
    // Add Section
    $wp_customize->add_section('pdf_section', array(
        'title'             => __('PDF', 'name-theme'), 
        'priority'          => 70,
    ));    
 
    // Add Controls
    $wp_customize->add_control( new WP_Customize_Upload_Control( $wp_customize, 'customizer_setting_pdf', array(
        'label'             => __('PDF Upload', 'name-theme'),
        'section'           => 'pdf_section',
        'settings'          => 'customizer_setting_pdf',    
    )));
}
add_action('customize_register', 'pdf_customize_register');

2) Displaying in the Front End

<a href="<?php echo esc_url( get_theme_mod( 'customizer_setting_pdf' ) ); ?>">Download PDF</a>

Filed Under: Free Tagged With: PHP

How to add social icons to Storefront nav menu

// =========================================================================
// ADD SOCIAL ICON TO NAV MENU
// =========================================================================
function wdm_add_menu_items( $menu, $args ) {
    // check if it is the 'primary' navigation menu
    if ( 'primary' === $args->theme_location || 'handheld' === $args->theme_location)
    {
      // add the search form
      ob_start();
      $menu  .= '<li id="menu-item-5000" class="menu-item menu-icon">
                    <a target="_blank" href="">
                        <i class="fab fa-instagram"></i>
                    </a>
                </li>
                <li id="menu-item-6000" class="menu-item menu-icon">
                    <a target="_blank" href="">
                        <i class="fab fa-facebook-f"></i>
                    </a>
                </li>
                
                ';
      ob_get_clean();
    }
    return $menu;
}
add_filter( 'wp_nav_menu_items', 'wdm_add_menu_items', 10, 2 );

Filed Under: Free Tagged With: Storefront

Masonry layout with Bootstrap – grid cloumns

If You would like to implement only the masonry component of bootstrap

//CARD COLUMNS
.card-columns .card {
  margin-bottom: 0.75rem;
}

@media (min-width: 576px) {
  .card-columns {
    -webkit-column-count: 3;
    -moz-column-count: 3;
    column-count: 3;
    -webkit-column-gap: 1.25rem;
    -moz-column-gap: 1.25rem;
    column-gap: 1.25rem;
    orphans: 1;
    widows: 1;
  }
  .card-columns .card {
    display: inline-block;
    width: 100%;
  }
}

HTML structure with WordPress loop

<?php
wp_reset_postdata();
  
$args = array(
    'post_type' => 'post_type',
    'posts_per_page' => -1
);
  
$the_query = new WP_Query( $args ); ?>
 
    <div class="card-columns">
        
        <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
     
           <div class="card">
                
                <!---->
               
            </div>
 
        <?php endwhile; endif; ?>
    </div>
 
<?php wp_reset_postdata(); ?>

Filed Under: Free Tagged With: Bootstrap

Add page slug to body_class

// =========================================================================
// ADD PAGE SLUG TO BODY CLASS
// =========================================================================
function add_slug_to_body_class( $classes ) {
    global $post;
    if ( isset( $post ) ) {
        $classes[] = $post->post_name;
    }
    return $classes;
}
add_filter( 'body_class', 'add_slug_to_body_class' );

Filed Under: Free Tagged With: PHP

How to create custom Hooks in WordPress

1) Define the custom hook in functions.php

function latest_products_hook() {
	do_action('latest_products_hook');
}

2) Place anywhere you want in your template files

<?php latest_products_hook(); ?>

3) Create the function

add_action( 'latest_products_hook', 'storefront_recent_products', 30);

Filed Under: Free Tagged With: WordPress

How to change the color of Ninja Form placeholder

.nf-field-container .field-wrap .nf-element::placeholder {
	color: orange;
}

Filed Under: Free Tagged With: CSS

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 8
  • Page 9
  • Page 10
  • Page 11
  • Page 12
  • Interim pages omitted …
  • Page 19
  • Go to Next Page »

Primary Sidebar

Gabor Flamich

Hi! I'm Gabor.
I write tutorials on WordPress and WooCommerce.

MacBook

12 Essential Snippets for Genesis Developers

Subscribe to my Newsletter to view my basic collection of Genesis snippets that I use for my projects!

Sign Up for Free
  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube
UpdraftPlus Premium

Tags

ACF Ajax Analytics API Bootstrap Breadcrumb category CPT CSS fetch FSE Genesis Google Maps Gutenberg HTML Isotope JavaScript jQuery loop Map Menu Parallax PHP Rest API SASS SEO SQL Storefront SVG tab tag manager tags Taxonomy Tool upsell Webpack Wholesale WooCommerce WordPress WPML

Disclosure: Some of the links in this site are affiliate links. I will be paid a commission if you use this link to make a purchase.

  • Privacy Policy / Terms of Service
© 2025 WP Flames - All Right Reserved