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

Free

How to remove ‘Menu’ text in Genesis mobile navigation

1) You need to find this file: genesis-sample/config/responsive-menus.php

2) Add this line of code before the line menuClasses:

'mainMenu'    => __( '', 'genesis-sample' ),

3) The full code need to look like this:

return [
	'script' => [
        'mainMenu'    => __( '', 'genesis-sample' ),
		'menuClasses' => [
			'others' => [ '.nav-primary' ],
		],
	],
	'extras' => [
		'media_query_width' => '960px',
	],
];

Filed Under: Free Tagged With: Genesis

How to force hamburger menu on desktop in Genesis

All You need to do is just add some rows of CSS:

.genesis-responsive-menu {
	display: none;
}
.menu-toggle, .sub-menu-toggle {
	display: block;
	visibility: visible;
}

Filed Under: Free Tagged With: Genesis

How to get Advanced Custom Field slug

<?php $anchor = strtolower(str_replace(array(' ', ':'), array('-', ''), get_sub_field('title'))); ?>
<a href="#<?php echo $anchor; ?>"><?php the_sub_field('title'); ?></a>
<h2 id="<?php echo $anchor; ?>" class="headline"><?php the_sub_field('title'); ?></h2>

Filed Under: Free Tagged With: ACF

Disallow PNG upload in WordPress

In this snippet the are going to allow to upload only jpg and pdf format.

// =========================================================================
// DISALLOW PNG, GIF, TIF
// =========================================================================
function theme_restrict_mime_types( $mime_types ){
    $mime_types = array(
        'pdf' => 'application/pdf',
        'jpg|jpeg' => 'image/jpeg',
    );
    return $mime_types;
}
add_filter( 'upload_mimes', 'theme_restrict_mime_types' );

Filed Under: Free

Add Image Size to Advanced Custom Fields

Crop-Thumbnails

add_image_size('pageBanner', 1500, 300, true);
$pageBannerImage = get_field('page_banner_image');
echo $pageBannerImage['sizes']['pageBanner'];
<?php echo wp_get_attachment_image_src( get_field('field_name'), 'medium' )[0]; ?>
<?php
    $attachment_id = get_field('image');
    $size = 'gallery-thumb';
    $image = wp_get_attachment_image_src( $attachment_id, $size )[0];
?>
       
<div class="col-md-3">
    <div class="card">
        <div class="card-img-top">
            <a href="<?php the_field('link'); ?>">
                <img src="<?php echo $image; ?>" alt="<?php the_field('title'); ?>">
            </a>
        </div>
        <div class="card-body">
            <h4 class="card-title"><?php the_field('title'); ?></h4>
        </div>
    </div>    
</div>   

Filed Under: Free Tagged With: ACF

How to Make Custom Post Type Child of Page

'rewrite' => array(
            'slug' =>  get_post_field( 'post_name', get_option('cpt_parent_page') ) . '/PARENT/YOUR_POST_TYPE',
            'with_front' => false
)

Filed Under: Free Tagged With: CPT

Change the Structure of Custom Post Type’s Breadcrumb in Single Page

// =========================================================================
// FIX BREADCRUMB IN CUSTOM POST TYPE
// =========================================================================
function add_custom_breadcrumb(){
    if(is_singular('YOUR_CPT')){
        if ( function_exists('yoast_breadcrumb') ) :
          $post_types = array('YOUR_CPT');    

            ?>
            <div class="breadcrumb custom">
                <span xmlns:v="http://rdf.data-vocabulary.org/#">
                    <span typeof="v:Breadcrumb"><a href="<?php echo home_url(); ?>/" rel="v:url" property="v:title">Home</a></span> / 
                    <a href="#">Page 1</a> / 
                    <a href="#">Page 2</a> /
                    <a href="#">Page 3</a> /
                    <?php the_title(); ?>
                    <span typeof="v:Breadcrumb"><strong class="breadcrumb_last" property="v:title"><?php post_type_archive_title(); ?></strong></span>
                </span>
            </div>
            <?php
            else :
                yoast_breadcrumb('<div class="breadcrumb"> ','</div>');

        endif;
    }
}
add_action('genesis_before_loop', 'add_custom_breadcrumb');

Filed Under: Free Tagged With: PHP

Add Three Column Layout to Genesis Front Page and Two Column for Other Pages

1) Go to Customizer / Theme Settings/ Site Layout / Select Site Layout to Secondary Sidebar – Content – Primary Sidebar
2) Add this snippet to functions.php

// =========================================================================
// ADD SECONDARY SIDEBAR - CONTENT - SIDEBAR - 3 COL LAYOUT TO FRONT-PAGE
// =========================================================================
function add_three_column_layout_to_frontpage() {
    if ( !is_front_page() ) {
        return 'content-sidebar';
    }
}
add_filter( 'genesis_pre_get_option_site_layout', 'add_three_column_layout_to_frontpage' );

Filed Under: Free Tagged With: Genesis

Disable Gutenberg only for Posts

// =========================================================================
// DISABLE GUTENBERG FOR POSTS
// =========================================================================
function wpflames_disable_gutenberg($is_enabled, $post_type) {
	
	if ($post_type === 'post') return false; // it could be any kind of custom post type
	
	return $is_enabled;
	
}
add_filter('use_block_editor_for_post_type', 'wpflames_disable_gutenberg', 10, 2);

Filed Under: Free Tagged With: Gutenberg, PHP

ACF Post Object with Multiple Options

<?php

/*
*  Loop through post objects (assuming this is a multi-select field) ( don't setup postdata )
*  Using this method, the $post object is never changed so all functions need a seccond parameter of the post ID in question.
*/

$post_objects = get_field('YOUR_CUSTOM_FIELD');

if( $post_objects ): ?>
    <ul>
    <?php foreach( $post_objects as $post_object): ?>
        <li>
            <a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID); ?></a>
        </li>
    <?php endforeach; ?>
    </ul>
<?php endif;

?>

Filed Under: Free Tagged With: ACF

ACF Post Object for Related Posts with Repeater Field

   <?php if( have_rows('ITEMS') ): ?>

        <?php while ( have_rows('ITEMS') ) : the_row(); ?>   

                <?php $post_object = get_sub_field('ITEM'); ?>

                <?php if( $post_object ): ?>

                    <?php $post = $post_object; setup_postdata( $post ); ?>

                       <h4><?php echo get_the_title($post_object->ID); ?></h4>

                    <?php wp_reset_postdata(); ?>

                <?php endif; ?>

            <?php endwhile; ?>

<?php endif; ?>

Filed Under: Free Tagged With: ACF

Add sub-page to body_class if it’s not front-page

// =========================================================================
// ADD SUBPAGE BODY CLASS 
// =========================================================================
function body_class_subpage($classes) {
    global $wpdb, $post;
    if(!is_front_page()){
       $classes[] = 'sub-page';
    }
    return $classes;
}
add_filter('body_class','body_class_subpage'); 

Filed Under: Free Tagged With: PHP

Simple Bar – Scroll Bar

DEMO

funtcions.php

// =========================================================================
// SIMPLE BAR 
// =========================================================================
function simple_bar() {  
    if(is_front_page()){
        wp_enqueue_style('simple_bar_css', 'https://unpkg.com/simplebar@latest/dist/simplebar.min.css');
        wp_enqueue_script('simple_bar_js', 'https://unpkg.com/simplebar@latest/dist/simplebar.js', array(), '4.1.0', true );
    }
}
add_action( 'wp_enqueue_scripts', 'simple_bar' );

HTML

<div class="demo1" data-simplebar>
      <h2>Scroll me!</h2>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Scroll me!</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Scroll me!</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
      <p class="odd">Some content</p>
      <p>Some more content</p>
</div>

CSS

.demo1 {
  height: 376px;
  max-width: 100%;
}

Filed Under: Free Tagged With: JavaScript

Remove “You are here” from Genesis breadcrumb

// =========================================================================
// REMOVE YOU ARE HERE FROM BREADCRUMB
// =========================================================================
add_filter( 'genesis_breadcrumb_args', 'afn_breadcrumb_args' );
function afn_breadcrumb_args( $args ) {
	$args['labels']['prefix'] = '';
return $args;
}

Filed Under: Free Tagged With: Genesis

Remove menu items from WordPress admin

Remove menu items for specific user roles

Filed Under: Free Tagged With: PHP

Genesis translations

<?php
// =========================================================================
// GENESIS TRANSLATIONS WITHOUT LOCO TRANSLATE
// =========================================================================
function genesis_hungarian_translations( $translated, $original, $domain ) {
    if ( $translated == "Leave a Comment" ) { $translated = "Hozzászólás írása"; }
    if ( $translated == "by" ) { $translated = "Szerző: "; }
    if ( $translated == "Filed Under: " ) { $translated = "Kategória: "; }
    if ( $translated == "Tagged With: " ) { $translated = "Címkék: "; }
return $translated;
}
add_filter( 'gettext', 'genesis_hungarian_translations', 10, 3 );

Filed Under: Free Tagged With: Genesis

Add category and tag support to pages in WordPress

// =========================================================================
// ADD CATEGORY SUPPORT TO PAGES
// =========================================================================
function add_categories_to_pages() {
    register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'add_categories_to_pages' );


// =========================================================================
// ADD TAG SUPPORT TO PAGES
// =========================================================================
function tags_support_all() {
	register_taxonomy_for_object_type('post_tag', 'page');
}
add_action('init', 'tags_support_all');

Filed Under: Free Tagged With: PHP

How to move additional information after add to cart button

// =========================================================================
// REMOVE ADDITIONAL INFORMATION TAB
// =========================================================================
add_filter( 'woocommerce_product_tabs', 'remove_additional_information_tab', 100, 1 );
function remove_additional_information_tab( $tabs ) {
    unset($tabs['additional_information']);

    return $tabs;
}

// =========================================================================
// ADD ADDITIONAL INFORMATION AFTER ADD TO CART
// =========================================================================
add_action( 'woocommerce_single_product_summary', 'additional_info_under_add_to_cart', 35 );
function additional_info_under_add_to_cart() {
    global $product;

    if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
        wc_display_product_attributes( $product );
    }
}

Filed Under: Free Tagged With: WooCommerce

How to show custom message based on shipping class on single product page

// =========================================================================
// Custom Text on Product Page based on Shipping Class 
// =========================================================================
function display_shipping_class_on_product_page() {
    $product = wc_get_product();

    $shipping_class = $product->get_shipping_class();

    switch ( $shipping_class ) {
        case 'your_shipping_class_1':
            echo '';
            break;
        case 'your_shipping_class_2':
            echo '';
            break;
    }
}
add_action( 'woocommerce_single_product_summary', 'display_shipping_class_on_product_page', 10 );

Filed Under: Free Tagged With: WooCommerce

Two-third / One-third Gutenberg columns

/* Small devices (tablets, 768px and up) */
@media (min-width: 768px) {  
 .two-third .wp-block-column:first-child {
	flex-basis: 66%;
  }
}

Filed Under: Free Tagged With: Gutenberg

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