Skip to content

Instantly share code, notes, and snippets.

View shubhw12's full-sized avatar
🎯
Focusing

Shubham Wagh shubhw12

🎯
Focusing
  • Pune
View GitHub Profile
@shubhw12
shubhw12 / gist:29d9dfa511ab9ed39cfcb2af0eaa68e5
Created June 22, 2020 15:17
Change the place holder for the default search widget.
function custom_search_form( $form ) {
$form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
<label>
<span class="screen-reader-text">' . _x( 'Search for:', 'label', 'astra' ) . '</span>
<input type="search" class="searce-field" ' . apply_filters( 'astra_search_field_toggle_data_attrs', '' ) . ' placeholder="' . apply_filters( 'astra_search_field_placeholder', esc_attr_x( 'Your place holder', 'placeholder', 'astra' ) ) . '" value="' . get_search_query() . '" name="s" role="search" tabindex="-1"/>
</label>
<input type="submit" class="search-submit" value="Search">
</form>';
return $form;
@shubhw12
shubhw12 / gist:ebb2d90e5cfcb305478e4a7278436885
Created June 22, 2020 09:46
Add custom image background to advance header (page header ) on shop page.
add_action('wp', 'featured_image_call_back');
function featured_image_call_back(){
if(is_shop()){
add_filter('astra_advanced_headers_title_bar_bg', 'adv_header_call_back');
function adv_header_call_back(){
//Your featured image URL here:
return 'http://woo-commerce.test/wp-content/uploads/2020/05/men-fashion-free-img.jpg';
}
@shubhw12
shubhw12 / gist:76d901d5cc18e304f737cf7b4c83a0f7
Last active July 29, 2023 13:20
Remove add to cart button in astra theme.
//Remove add to cart from shop page.
add_filter('astra_woo_shop_product_structure' , 'call_back_add_to_cart_shop');
//Remove add to cart from single product page.
add_filter( 'astra_woo_single_product_structure' , 'call_back_add_to_cart' );
function call_back_add_to_cart_shop(){
$structure = astra_get_option( 'shop-product-structure' );
$add_to_cart_key = array_search('add_cart', $structure);
unset($structure[$add_to_cart_key]);
return $structure;
@shubhw12
shubhw12 / gist:0ee12aa03cb4461000d4ba506d99c475
Created June 3, 2020 14:47
Display the product title above the product images on product archive pages.
function woocommerce_template_loop_product_title(){
return ;
}
add_action('woocommerce_before_shop_loop_item_title','astra_woo_shop_products_title', 5);
function astra_woo_shop_products_title() {
echo '<a href="' . esc_url( get_the_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
echo '<h2 class="woocommerce-loop-product__title">' . esc_html( get_the_title() ) . '</h2>';
@shubhw12
shubhw12 / gist:954f3320ee5eab158684ecb1399eb8ec
Created May 20, 2020 09:12
Show products from the same product category.
add_action('wp' , 'remove_prev_next' , 50 );
function remove_prev_next(){
remove_action( 'woocommerce_single_product_summary', array( ASTRA_Ext_WooCommerce_Markup::get_instance(), 'next_previous_links' ), 1, 0 );
}
add_action('wp' , 'add_prev_next' , 100 );
function add_prev_next(){
if ( 'disable' != astra_get_option( 'single-product-nav-style' ) ) {
add_filter( 'astra_system_fonts', 'my_custom_fonts' );
function my_custom_fonts(){
$system_custom_fonts = array(
'Helvetica' => array(
'fallback' => 'Verdana, Arial, sans-serif',
'weights' => array(
'300',
'400',
'700',
@shubhw12
shubhw12 / gist:ffb13c42f3046ed2a04b50850f7bed75
Created April 8, 2020 08:32
Remove Author link from the author card.
add_filter('astra_post_author_output' , 'call_back');
function call_back(){
$author_info_array = sprintf(
'<div class="ast-single-author-box" %2$s itemscope itemtype="https://schema.org/Person">%1$s</div>',
sprintf(
'<div class="ast-author-meta"> <div class="about-author-title-wrapper"> <h3 class="about-author">%1$s</h3> </div> <div class="ast-author-details"> <div class="post-author-avatar">%2$s</div> <div class="post-author-bio"> <a class="url fn n" %6$s rel="author"> <h4 class="author-title" %7$s>%4$s</h4> </a> <div class="post-author-desc">%5$s</div> </div> </div> </div>',
esc_html__( 'About The Author', 'astra-addon' ),
get_avatar( get_the_author_meta( 'email' ), 100 ),
@shubhw12
shubhw12 / gist:a2527779f4c61288cab770d68ef0866b
Created April 8, 2020 07:49
Remove author link from the post meta
add_filter('astra_post_author' , 'author_call_back', 15 );
function author_call_back(){
ob_start();
echo '<span ';
echo astra_attr(
'post-meta-author',
array(
@shubhw12
shubhw12 / gist:1079072f1787beb307420606b7c2b726
Created March 27, 2020 14:38
Display author meta on CPT
add_action( 'astra_primary_content_bottom' , 'author_meta_callback' );
function author_meta_callback(){
if ( 'post' !== get_post_type() ){
if (function_exists('astra_get_template')){
if ( astra_get_option( 'ast-author-info' ) && is_singular( ) ) {
astra_get_template( 'blog-pro/template/author-info.php' );
}
}
}
@shubhw12
shubhw12 / gist:7856b0f0a41037725acedc6cf04f2eb7
Created March 27, 2020 11:46
Display post meta for custom post type in astra on single post page
add_action('astra_single_post_title_after', 'callback_function');
function callback_function(){
if ( 'post' !== get_post_type() ){
$enable_meta = apply_filters( 'astra_blog_post_meta_enabled', '__return_true' );
$post_meta = astra_get_option( 'blog-meta' );
if ( is_array( $post_meta ) && $enable_meta ) {