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

Free

Loop team members

<?php
wp_reset_postdata();

$args = array(
'post_type' => 'team',
'posts_per_page' => 100
);

$the_query = new WP_Query( $args );
?>
<div class="container">
<div class="row">
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<div class="col-md-4">

<div class="card member">
<a href="<?php the_permalink(); ?>">
<img class="card-img-top" src="<?php the_field('image'); ?>" alt="">
</a>
<div class="card-body">
<h3 class="card-title"><?php the_title(); ?></h3>
<p class="card-text hidden"><?php the_field('description'); ?></p>
<a class="hidden" href="<?php the_permalink(); ?>" class="btn btn-primary">Read more</a>
</div>
</div>
</div>

<?php endwhile; endif; ?>

</div><!--row-->

</div><!--container-->

<?php wp_reset_postdata(); ?>

Filed Under: Free Tagged With: PHP

Add Product to WooCommerce Cart Automatically


add_action( 'template_redirect', 'snippet_add_product_to_cart' );

function snippet_add_product_to_cart() {

// select ID
$product_id = 21874;

//check if product already in cart
if ( WC()->cart->get_cart_contents_count() == 0 ) {

// if no products in cart, add it
WC()->cart->add_to_cart( $product_id );

}

}

Filed Under: Free Tagged With: WooCommerce

Add Product to Cart When Visiting a Specific Page ID


add_action( 'wp', 'add_product_to_cart_on_page_id_load' );

function add_product_to_cart_on_page_id_load() {

// product ID to add to cart
$product_id = 21874;

// page ID to target
if ( is_page( 19473 ) ) {
WC()->cart->empty_cart();
WC()->cart->add_to_cart( $product_id );
}

}

Filed Under: Free Tagged With: WooCommerce

Genesis Custom Footer

Filed Under: Free Tagged With: Genesis

Simple shortcode function

If the shortcode produces a lot of HTML then ob_start can be used to capture output and convert it to a string as follows:

Filed Under: Free Tagged With: PHP

Add custom field to single product page


//ADD CUSTOM FIELD TO SINGLE PRODUCT BEFORE ADD TO CART BUTTON
add_action( 'woocommerce_single_variation', 'add_custom_field_before_addtocart', 5 );
function add_custom_field_before_addtocart() {
include('woo/custom-field.php');
}


<?php the_field('custom'); ?>

Filed Under: Free Tagged With: WooCommerce

Add custom widget to anywhere you want

Register widget in functions.php

 
// =========================================================================
// REGISTER NEW WIDGET
// =========================================================================
function custom_widgets_init() {

    register_sidebar( array(
            'name' => 'Custom Widget',
            'id' => 'custom-widget-id',
            'before_widget' => '<div class="custom-widget">',
            'after_widget' => '</div>',
            'before_title' => '<h4 class="custom-title">',
            'after_title' => '</h4>',
        ) );

}
add_action( 'widgets_init', 'custom_widgets_init' ); 

Place this code where you want to appear the widget


<?php dynamic_sidebar('Custom Widget'); ?> 

Filed Under: Free Tagged With: PHP

Facebook Likebox to Genesis

Filed Under: Free Tagged With: Genesis

Genesis cover

If You want to create a GSAP Animation for the cover build up with HTML, CSS and JavaScript and hook in to the frontpage’s before content:

GSAP Animations
Demo
Buy Snippet

Filed Under: Free Tagged With: Genesis

Translate without PO Edit


<?php
function wpf_filter_gettext( $translated, $original, $domain ) {
    if ( $translated == "OLD_TEXT" ) { $translated = "NEW_TEXT"; }
return $translated;
}
add_filter( 'gettext', 'wpf_filter_gettext', 10, 3 );

Remove translation


function remove_translation( $translated_text, $untranslated_text, $domain ) {

$removable_text = 'Ide kerül az eltávolítani kívánt kifejezés.';

if ($untranslated_text === $removable_text ) {
return '';
}

return $translated_text;
}

 

Filed Under: Free Tagged With: PHP

Add Conversion Tracking Code to Thank You Page


/**
* @snippet Add Conversion Tracking Code to Thank You Page
*/

add_action( 'woocommerce_thankyou', 'bbloomer_conversion_tracking_thank_you_page' );

function bbloomer_conversion_tracking_thank_you_page() {
?>
<!-- Google Code for Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 000000000000;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "kjsdhfkjhkfsdfsdf";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/000000000000/?label=kjdhfsdjfkjkjshdkkkjsdkk&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
<?php
}

Filed Under: Free Tagged With: Analytics

Add custom text below the table of email notification


add_action('woocommerce_email_after_order_table', 'add_email_shipping_text');
function add_email_shipping_text(){
echo '';
}

Filed Under: Free Tagged With: WooCommerce

Removing BACS instructions from email notifications in WooCommerce


add_action( 'woocommerce_email_before_order_table', function(){
if ( ! class_exists( 'WC_Payment_Gateways' ) ) return;

$gateways = WC_Payment_Gateways::instance(); // gateway instance
$available_gateways = $gateways->get_available_payment_gateways();

if ( isset( $available_gateways['bacs'] ) )
remove_action( 'woocommerce_email_before_order_table', array( $available_gateways['bacs'], 'email_instructions' ), 10, 3 );
}, 1 );

Filed Under: Free Tagged With: WooCommerce

How to change WooCommerce email subject


{order_date} keltezésű {site_title} rendelés visszaigazolása

Filed Under: Free Tagged With: WooCommerce

Redirect Contact Form 7 to thank you page

</pre>
//Redirect Contact Form 7 to custom thank you page
add_action( 'wp_footer', 'redirect_cf7' );

function redirect_cf7() {

echo '<script type="text/javascript">
document.addEventListener( "wpcf7mailsent", function( event ) {
if ( "form_id" == event.detail.contactFormId ) {
location = "link";
}
}, false );
</script>';
}
<pre>

Filed Under: Free Tagged With: JavaScript

WooCommerce emails based on payment method


function add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
    $payment_method = $order->payment_method;
    if ( $payment_method == 'bacs' ) {
        echo 'Your text';
    }
}
add_action( 'woocommerce_email_before_order_table', 'add_content_specific_email', 20, 4 );

Filed Under: Free Tagged With: WooCommerce

Disable Comments in WordPress

<?php
/**
 * Plugin Name: Disable Comments
 * Plugin URI: https://codex.wordpress.org
 * Author: @wpflames
 */

// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
	$post_types = get_post_types();
	foreach ($post_types as $post_type) {
		if(post_type_supports($post_type, 'comments')) {
			remove_post_type_support($post_type, 'comments');
			remove_post_type_support($post_type, 'trackbacks');
		}
	}
}
add_action('admin_init', 'df_disable_comments_post_types_support');

// Close comments on the front-end
function df_disable_comments_status() {
	return false;
}
add_filter('comments_open', 'df_disable_comments_status', 20, 2);
add_filter('pings_open', 'df_disable_comments_status', 20, 2);

// Hide existing comments
function df_disable_comments_hide_existing_comments($comments) {
	$comments = array();
	return $comments;
}
add_filter('comments_array', 'df_disable_comments_hide_existing_comments', 10, 2);

// Remove comments page in menu
function df_disable_comments_admin_menu() {
	remove_menu_page('edit-comments.php');
}
add_action('admin_menu', 'df_disable_comments_admin_menu');

// Redirect any user trying to access comments page
function df_disable_comments_admin_menu_redirect() {
	global $pagenow;
	if ($pagenow === 'edit-comments.php') {
		wp_redirect(admin_url()); exit;
	}
}
add_action('admin_init', 'df_disable_comments_admin_menu_redirect');

// Remove comments metabox from dashboard
function df_disable_comments_dashboard() {
	remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
}
add_action('admin_init', 'df_disable_comments_dashboard');

// Remove comments links from admin bar
function df_disable_comments_admin_bar() {
	if (is_admin_bar_showing()) {
		remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
	}
}
add_action('init', 'df_disable_comments_admin_bar');
//END DISABLE COMMENTS




//REMOVE LOST PASSWORD
function remove_lostpassword_text ( $text ) {
	 if ($text == 'Elfelejtett jelszó?'){$text = '';}
		return $text;
	 }
add_filter( 'gettext', 'remove_lostpassword_text' );

Filed Under: Free Tagged With: PHP

Shipping method – Show only the selected description


function syslab_update_order_review_fragments( $array ) {
// make filter magic happen here...
$array['.woocommerce-checkout-review-order-table'] = $array['.woocommerce-checkout-review-order-table'].'<script>jQuery(".shipping_method:checked").parent("li").find(".shipping-desc").stop().show();</script>';
return $array;
};
// add the filter
add_filter( 'woocommerce_update_order_review_fragments', 'syslab_update_order_review_fragments', 10, 1 );

Filed Under: Free Tagged With: WooCommerce

Customize search.php

function genesis_do_search_title() {

global $wp_query;
$total_results = $wp_query->found_posts;

$title = sprintf( '<div class="archive-description"><h1 class="archive-title">%s '. $total_results .' találat a "%s" kifejezésre </h1></div>', apply_filters( 'genesis_search_title_text', __( 'Search Results for:', 'genesis' ) ), get_search_query() );

echo apply_filters( 'genesis_search_title_output', $title ) . "\n";

}

Filed Under: Free Tagged With: PHP

Fix broken lightbox on product single page


add_action( 'after_setup_theme', 'yourtheme_setup' );

function yourtheme_setup() {
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}

Filed Under: Free Tagged With: WooCommerce

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 15
  • Page 16
  • Page 17
  • Page 18
  • 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