• 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 12

Free

Add page title with featured image as background in Genesis

Step #1 Create a file with name “page-title.php”

You can set a static background image in the else statement, just replace the dotted line with your uploaded image URL:

Step #2 Add this snippet to functions.php

Step #3 Add this to your CSS

Filed Under: Free Tagged With: Genesis

Custom Post Type and Taxonomy

Create file named post-types.php in the mu-plugins (must use) folder:

wp-content/mu-plugins/post-types.php

If You’re using variables, only it’s name need to be changed

You can use more parameters

Remove slug from custom post type post URLs

If You don’t want to use the Custom Post Type’s slug, just paste this snippet in your functions.php and rewrite the post type:

Filed Under: Free Tagged With: CPT

How to list categories in a dropdown menu

<?php
    if( $terms = get_terms( array(
        'taxonomy' => 'category', // to make it simple I use default categories
        'orderby' => 'name'
    ) ) ) : 
        // if categories exist, display the dropdown
        echo '<div class="isotope-filter-wrapper">';
            echo '<select name="categoryfilter"><option value="">Select category...</option>';
            foreach ( $terms as $term ) :
                echo '<option value="' . $term->term_id . '">' . $term->name . '</option>'; // ID of the category as an option value
            endforeach;
            echo '</select>';
        echo '</div>';
    endif;  
?>

Filed Under: Free Tagged With: PHP

How to Remove Storefront Page Title

// =========================================================================
// REMOVE STOREFRONT PAGE TITLE
// =========================================================================
function storefront_remove_title() {
    remove_action( 'storefront_page', 'storefront_page_header' );
}
add_action( 'wp', 'storefront_remove_title' );

Filed Under: Free Tagged With: Storefront

WordPress Loop

Display posts on specific pages with WordPress loop

Loop WordPress post titles:

Loop WordPress post titles

You can use these WordPress core functions inside the loop:

the_title();
the_excerpt();
the_content();
the_permalink();
the_post_thumbnail();

Place these PHP functions in your HTML structure and add some line of CSS

Filed Under: Free Tagged With: WordPress

Genesis Loop with Pagination

Filed Under: Free Tagged With: Genesis

Add custom image size to media image

// =========================================================================
// ADD CUSTOM IMAGE SIZE 
// =========================================================================
add_image_size( 'custom-size', 800, 540, array( 'left', 'top' ) ); // Hard crop left top

Filed Under: Free Tagged With: PHP

Add class to the excerpt with filter

// =========================================================================
// ADD CLASS TO EXCERPT
// =========================================================================
add_filter( "the_excerpt", "add_class_to_excerpt" );

function add_class_to_excerpt( $excerpt ) {
    return str_replace('<p', '<p class="card-text"', $excerpt);
}

Filed Under: Free Tagged With: PHP

Add cart icon with item numbers to Storefront header

// =========================================================================
// REMOVE ACCOUNT AND SEARCH ICON FROM storefront-handheld-footer-bar
// =========================================================================
function jk_remove_handheld_footer_links( $links ) {
	unset( $links['my-account'] );
	unset( $links['search'] );
	return $links;
}
add_filter( 'storefront_handheld_footer_bar_links', 'jk_remove_handheld_footer_links' );

// =========================================================================
// REMOVE STOREFRONT HANDHELD BAR
// =========================================================================
function remove_storefront_handheld_footer_bar() {
  remove_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 );
}
add_action( 'init', 'remove_storefront_handheld_footer_bar' );

// =========================================================================
// MOVE STOREFRONT HANDHELD FOOTER BAR WITH CART ICON TO HEADER
// =========================================================================
add_filter( 'storefront_header', 'storefront_handheld_footer_bar' );

Filed Under: Free Tagged With: Storefront

Shortcode with attributes – custom link and text

// =========================================================================
// BUTTON SHORTCODE WITH ATTRIBUTES
// =========================================================================
function btn_shortcode( $atts, $content = null ) {
    $a = shortcode_atts( array(
        'href'  =>  '#',
        'text' => ''
    ), $atts );

    return '<a class="btn-cta" href="' . esc_attr($a['href']) . '">' . esc_attr($a['text']) . '</a>';
}
add_shortcode( 'button', 'btn_shortcode' );

Filed Under: Free Tagged With: PHP

Add parent page slug to body_class

// =========================================================================
// ADD PARENT PAGE SLUG TO BODY CLASS 
// =========================================================================
function body_class_section($classes) {
    global $wpdb, $post;
    if (is_page()) {
        if ($post->post_parent) {
            $parent = end(get_post_ancestors($current_page_id));
        } else {
            $parent = $post->ID;
        }
        $post_data = get_post($parent, ARRAY_A);
        $classes[] = 'parent-' . $post_data['post_name'];
    }
    return $classes;
}
add_filter('body_class','body_class_section'); 

Filed Under: Free Tagged With: PHP

Add top header widget to Storefront

// =========================================================================
// ADD CUSTOM WIDGET - TOP HEADER
// =========================================================================
add_action( 'widgets_init', 'register_new_top_header' );

function register_new_top_header() {

  register_sidebar(array(
    'id' => 'top-header',
    'name' => __( 'Top Header', 'storefront' ),
    'description' => __( 'Top Header.', 'storefront' ),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
  ));
}
// =========================================================================
// CREATE FUNCTION FOR TOP HEADER WIDGET 
// =========================================================================
function top_header_widget(){
    dynamic_sidebar('Top Header');
}
// =========================================================================
// HOOK THE WIDGET BEFORE HEADER
// =========================================================================
add_action( 'storefront_before_header', 'top_header_widget', 2 );

Filed Under: Free Tagged With: Storefront

Remove Storefront sidebar from single product, cart and checkout page

Filed Under: Free Tagged With: Storefront

Remove sidebar from cart page in Storefront

// =========================================================================
//REMOVE SIDEBAR OF STOREFRONT CART PAGE 
// =========================================================================
function remove_cart_sidebar_storefront() {
    if( is_cart()){
	    remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
        add_filter( 'body_class', function( $classes ) {
            return array_merge( $classes, array( 'page-template-template-fullwidth page-template-template-fullwidth-php ' ) );
        } );
    }
}
add_action( 'wp', 'remove_cart_sidebar_storefront' );

Filed Under: Free Tagged With: Storefront

Remove sidebar from single product page in Storefront

// =========================================================================
// REMOVE SIDEBAR FROM SINGLE PRODUCT PAGE IN STOREFRONT
// =========================================================================
add_action( 'get_header', 'wpninja_remove_storefront_sidebar' );
 
function wpninja_remove_storefront_sidebar() {
    if ( is_product() ) {
        remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
        add_filter( 'body_class', function( $classes ) {
            return array_merge( $classes, array( 'page-template-template-fullwidth page-template-template-fullwidth-php ' ) );
        } );
    }
}

Filed Under: Free Tagged With: Storefront

Conditionally add Full-Width Layout for Storefront with ACF and custom body_class

Create a True / False custom field with ACF Pro

Add this to functions.php

// =========================================================================
// FULL WIDTH CHECKBOX
// =========================================================================
function add_full_width_layout(){
     if( get_field('full_width') ){
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
       add_filter( 'body_class', function( $classes ) {
            return array_merge( $classes, array( 'page-template-template-fullwidth page-template-template-fullwidth-php ' ) );
        } );
    } 
}
add_action( 'wp', 'add_full_width_layout' );

Filed Under: Free Tagged With: Storefront

Remove Storefront built-in homepage sections

function remove_storefront_home_sections( $args ) {
    remove_action( 'homepage', 'storefront_product_categories', 20 );
    remove_action( 'homepage', 'storefront_recent_products', 30 );
    remove_action( 'homepage', 'storefront_featured_products', 40 );
    remove_action( 'homepage', 'storefront_popular_products', 50 );
    remove_action( 'homepage', 'storefront_on_sale_products', 60 );
    remove_action( 'homepage', 'storefront_best_selling_products', 70 );
}
add_action( 'wp', 'remove_storefront_home_sections' );

Filed Under: Free Tagged With: Storefront

Add Facebook Pixel to wp_head

// =========================================================================
// ADD FACEBOOK PIXEL TO WP_HEAD
// =========================================================================
function add_facebook_pixel() { ?>
   <!-- Facebook Pixel Code -->
    <script>
      !function(f,b,e,v,n,t,s)
      {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};
      if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
      n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t,s)}(window, document,'script',
      'https://connect.facebook.net/en_US/fbevents.js');
      fbq('init', 'xxxxxxxxxxx');
      fbq('track', 'PageView');
    </script>
    <noscript><img height="1" width="1" style="display:none"
      src="https://www.facebook.com/tr?id=xxxxxxxxxxx&ev=PageView&noscript=1"
    /></noscript>
    <!-- End Facebook Pixel Code -->
<?php } 
add_action('wp_head', 'add_facebook_pixel');


// =========================================================================
// ADD FACEBOOK CONVERSION EVENT SNIPPET TO THANK YOU PAGE
// =========================================================================
function conversion_tracking_thank_you_page() { ?>
    <script>
        fbq('track', 'Purchase');
    </script>';
<?php }
add_action( 'woocommerce_thankyou', 'conversion_tracking_thank_you_page' );

Filed Under: Free Tagged With: PHP

How to set different CSS on WPML languages

.your_selector:lang(de) {
	display: none !important;
}

Filed Under: Free Tagged With: CSS, WPML

How to get slug of current page?

<?php 
    global $post;
    $post_slug=$post->post_name;
?>

Filed Under: Free Tagged With: PHP

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 10
  • Page 11
  • Page 12
  • Page 13
  • Page 14
  • 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