Skip to content

Instantly share code, notes, and snippets.

View Balachandark's full-sized avatar

Balachandar Karuparthy Balachandark

  • India, Pune
View GitHub Profile
@Balachandark
Balachandark / functions.php
Last active January 3, 2024 20:19
Preload fonts
add_filter( 'astra_enable_default_fonts', 'temp_disable_astra_fonts' );
function temp_disable_astra_fonts( $load ) {
$load = false;
return $load;
}
add_action( 'wp_head', 'add_astra_fonts_preload', 1 );
function add_astra_fonts_preload() {
?>
<link rel="preload" href="<?php echo get_site_url(); ?>/wp-content/themes/astra/assets/fonts/astra.woff" as="font" crossorigin />
<link rel="preload" href="<?php echo get_site_url(); ?>/wp-content/themes/astra/assets/fonts/astra.ttf" as="font" crossorigin />
@Balachandark
Balachandark / functions.php
Last active December 17, 2019 08:59
Add new markup for navigation
add_action( 'wp', 'remove_astra_woocommerce_action', 11 );
function remove_astra_woocommerce_action(){
if( is_callable( 'ASTRA_Ext_WooCommerce_Markup::get_instance' ) ) {
remove_action( 'woocommerce_single_product_summary', array( ASTRA_Ext_WooCommerce_Markup::get_instance(), 'product_navigation_wrapper_start' ), 1, 0 );
remove_action( 'woocommerce_single_product_summary', array( ASTRA_Ext_WooCommerce_Markup::get_instance(), 'next_previous_links' ), 1, 0 );
remove_action( 'woocommerce_single_product_summary', array( ASTRA_Ext_WooCommerce_Markup::get_instance(), 'product_navigation_wrapper_end' ), 1, 0 );
}
}
add_action( 'wp', 'add_new_navigation_markup' );
@Balachandark
Balachandark / functions.php
Created December 6, 2019 10:00
change_title_tag
add_filter( 'astra_advanced_header_layout_1_title_tag', 'change_title_tag', 10, 1 );
add_filter( 'astra_advanced_header_layout_2_title_tag', 'change_title_tag', 10, 1 );
function change_title_tag( $tag ) {
$tag = 'h6';
return $tag;
}
@Balachandark
Balachandark / functions.php
Created December 6, 2019 10:00
change_title_tag
add_filter( 'astra_advanced_header_layout_1_title_tag', 'change_title_tag', 10, 1 );
add_filter( 'astra_advanced_header_layout_2_title_tag', 'change_title_tag', 10, 1 );
function change_title_tag( $tag ) {
$tag = 'h6';
return $tag;
}
@Balachandark
Balachandark / functions.php
Created December 6, 2019 10:00
change_title_tag
add_filter( 'astra_advanced_header_layout_1_title_tag', 'change_title_tag', 10, 1 );
add_filter( 'astra_advanced_header_layout_2_title_tag', 'change_title_tag', 10, 1 );
function change_title_tag( $tag ) {
$tag = 'h6';
return $tag;
}
@Balachandark
Balachandark / blog-layout-3.php
Created December 6, 2019 06:35
Blog Pro - Blog Layout 3 Template
<?php
/**
* Blog Pro - Blog Layout 3 Template
*
* @todo Update this template for Default Blog Style
*
* @package Astra Addon
*/
?>
@Balachandark
Balachandark / gist:b33c71baceb4a678a92702f034fc20c8
Created November 8, 2019 06:25
Add embedded code in custom layout
<?php
$uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); // Removes the leading slash.
$uri = rtrim( $uri, '/' ); // Removes the trailing slash.
$uri = str_replace('/', ' ', $uri); // Replaces the slashes with spaces.
?>
<script type="text/javascript" src="a.remarketstats.com/px/smart/?c=222ccaf40d04fb6&seg=<?php echo $uri; ?>" ></script>
@Balachandark
Balachandark / functions.php
Last active October 30, 2019 06:39
Add content before, after content and in between paragraphs
//Insert ads after fifth and seventh paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
// Add your after 5th paragraph ad code first and then the 7th paragraph ads code.
$ad_code = array(
'<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Mypt3 300x250 (M) -->
<ins class="adsbygoogle"
@Balachandark
Balachandark / functions.php
Created October 24, 2019 11:29
Add Elementor CSS file in Head
add_action( 'wp_enqueue_scripts', function() {
if ( ! class_exists( 'Elementor\Core\Files\CSS\Post' ) ) {
return;
}
// Add your header page id here.
$header_page_id = 3499;
$css_file = new Elementor\Core\Files\CSS\Post( $header_page_id );
$css_file->enqueue();
@Balachandark
Balachandark / functions.php
Created October 24, 2019 06:27
Remove CSS style coming from custom fonts
// Remove CSS style coming from custom fonts.
add_action( 'wp', 'remove_styles' );
function remove_styles() {
if( class_exists( 'Bsf_Custom_Fonts_Render' ) ) {
remove_action( 'wp_head', array( Bsf_Custom_Fonts_Render::get_instance(), 'add_style' ) );
}
}