Skip to content

Instantly share code, notes, and snippets.

function holiday_message_before_header() {
?>
<div class="header-block">
<?php echo do_shortcode( '[block id="YOUR BLOCK NAME"]' ); ?>
</div>
<?php
}
add_action( 'flatsome_before_header', 'holiday_message_before_header', 1 );
/*
flatsome [ux-countdown] shortcode usage
*/
//Admin side shortcode
[ux_countdown year="2019" month="10" day="30" time="15:00"]
//Add below in functions.php
echo do_shortcode('[ux_countdown year="2019" month="10" day="30" time="15:00"]');
<?php
/*
Flatsome Theme Product On-Sale End Counter
*/
function display_onsale_product_counter() {
global $product;
if ( $product->is_on_sale() )
<?php
//flatsome product detail page text after excerpt
function display_after_short_description($excerpt) {
$add_to_excerpt = $excerpt . "<p style='color:green'>Add anything after excerpt</p>";
return $add_to_excerpt;
}
// Place this in a text widget
<p class="mb-0"><i class="icon-checkmark cc-checkmark"></i> Worldwide shipping</p>
// Aditional CSS Flatsome > Advanced > Custom CSS
.icon-checkmark.cc-checkmark {
color: #7a9c59;
margin-right: 5px;
}
@KoolPal
KoolPal / Posted On - Byline
Created March 17, 2020 12:49 — forked from c-askew/Posted On - Byline
PHP Functions to add to Function.php to make various element contents easily edittable with CSS. Included so far - > Blog Posts "Posted On" & "Byline" - Edit inside post-pre / byline-pre spans
if ( ! function_exists( 'flatsome_posted_on' ) ) :
// Prints HTML with meta information for the current post-date/time and author.
function flatsome_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf( $time_string,
<?php
//flatsome display text after product detail page image, if product is on sale
function display_flatsome_after_product_images() {
global $product;
if ( $product->is_on_sale() )
{
echo '<div style="color:red; border:1px solid #ccc;">Limited time offer</div>';
}
<?php
// display text after flatsome cart sidebar
function display_text_after_flatsome_cart_sidebar()
{
echo '<b style="color:red; font-size:20px;">Limited time offer</b>';
}
add_action('flatsome_cart_sidebar', 'display_text_after_flatsome_cart_sidebar');
@KoolPal
KoolPal / low-stock-notification-custom-fields.php
Created March 6, 2020 05:57 — forked from fariasf/low-stock-notification-custom-fields.php
Low stock notification per product (adding custom fields)
<?php
/**
* Custom product field to set low stock threshold
* Requires WooCommerce 3.0
*/
function sp_custom_product_stock_threshold_field() {
global $post;
woocommerce_wp_text_input( array(
@KoolPal
KoolPal / wc-add-custom-product-field.php
Created February 26, 2020 09:45
WooCommerce functions
/* Add Custom field to WooCommerce product */
add_action( 'woocommerce_product_options_general_product_data', 'wc_custom_add_custom_fields' );
function wc_custom_add_custom_fields() {
woocommerce_wp_text_input( array(
'id' => '_delivery_field',
'label' => __( 'Delivery', 'pvc' ),
'description' => __( 'Enter the delivery time in days.', 'pvc' ),
'desc_tip' => 'true'
) );
}