/** * Functions and definitions * * @package Landmaster */ // Register optimized product image size add_action('after_setup_theme', function() { add_image_size('product-medium-optimized', 650, 550, true); }); // Replace full size images with optimized size on frontend add_filter('post_thumbnail_size', function($size) { if (!is_admin()) { return 'product-medium-optimized'; } return $size; }); // Keep the first featured image high priority for LCP, but let WordPress // handle the rest of the image loading heuristics natively. add_filter('wp_get_attachment_image_attributes', function($attr, $attachment, $size) { if (is_admin()) { return $attr; } static $lcp_image_marked = false; $classes = isset($attr['class']) ? (string) $attr['class'] : ''; $is_featured_image = strpos($classes, 'wp-post-image') !== false; if ($is_featured_image && ! $lcp_image_marked) { $attr['loading'] = 'eager'; $attr['fetchpriority'] = 'high'; $attr['decoding'] = 'async'; $lcp_image_marked = true; return $attr; } unset($attr['loading'], $attr['fetchpriority']); return $attr; }, 10, 3); add_action('wp_head', function() { if (is_admin() || ! (is_singular('product') || is_shop())) { return; } $thumb_id = get_post_thumbnail_id(get_queried_object_id()); if (! $thumb_id) { return; } $src = wp_get_attachment_image_url($thumb_id, 'full'); if ($src) { printf( "\n", esc_url($src) ); } }, 1); // Remove Google Tag Manager / GA scripts completely add_action('template_redirect', function () { ob_start(function ($buffer) { $buffer = preg_replace('#]*googletagmanager\.com/gtag/js\?id=G-97X8YZX1G1[^>]*>#i', '', $buffer); $buffer = preg_replace('#]*googletagmanager\.com/gtag/js\?id=GT-WBZKH75[^>]*>#i', '', $buffer); $buffer = preg_replace_callback( '/]*class="[^"]*wp-post-image[^"]*"[^>]*>/', function ($matches) { $tag = preg_replace('/\sloading="lazy"/', '', $matches[0]); if (strpos($tag, 'fetchpriority=') === false) { $tag = preg_replace('/ esc_html__( 'Primary', 'landmaster' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'landmaster_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); // Add support for core custom logo. add_theme_support( 'custom-logo', array( 'height' => 250, 'width' => 250, 'flex-width' => true, 'flex-height' => true, ) ); add_theme_support( 'post-formats', array( 'gallery', 'video', ) ); // woocommerce add_theme_support( 'woocommerce' ); add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); /* Add theme image size */ add_image_size( 'landmaster-medium', 768, 768, true ); // For WP 5.8 remove_theme_support('widgets-block-editor'); } endif; add_action( 'after_setup_theme', 'landmaster_setup' ); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * */ function landmaster_content_width() { $GLOBALS['content_width'] = apply_filters( 'landmaster_content_width', 640 ); } // Allow WebP image uploads function allow_webp_uploads($mime_types) { $mime_types['webp'] = 'image/webp'; return $mime_types; } add_filter('upload_mimes', 'allow_webp_uploads'); // Add WebP support to the media library function webp_is_displayable($result, $path) { if ($result === false) { $displayable_image_types = array( IMAGETYPE_WEBP ); $info = @getimagesize( $path ); if (isset($info['2']) && in_array($info['2'], $displayable_image_types)) { return true; } } return $result; } add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2); add_action( 'after_setup_theme', 'landmaster_content_width', 0 ); /** * Register widget area. */ function landmaster_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Blog Sidebar', 'landmaster' ), 'id' => 'sidebar-blog', 'description' => esc_html__( 'Add widgets here.', 'landmaster' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); if (class_exists('ReduxFramework')) { register_sidebar(array( 'name' => esc_html__('Page Sidebar', 'landmaster'), 'id' => 'sidebar-page', 'description' => esc_html__('Add widgets here.', 'landmaster'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name' => esc_html__( 'Project Sidebar', 'landmaster' ), 'id' => 'sidebar-portfolio', 'description' => esc_html__( 'Add widgets here.', 'landmaster' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => esc_html__( 'Service Sidebar', 'landmaster' ), 'id' => 'sidebar-service', 'description' => esc_html__( 'Add widgets here.', 'landmaster' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } if ( class_exists( 'Woocommerce' ) ) { register_sidebar( array( 'name' => esc_html__( 'Shop Sidebar', 'landmaster' ), 'id' => 'sidebar-shop', 'description' => esc_html__( 'Add widgets here.', 'landmaster' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } if (class_exists('ReduxFramework')) { $footer_top_column = landmaster_get_opt( 'footer_top_column', '4' ); if ( isset( $footer_top_column ) && $footer_top_column ) { for ( $i = 1; $i <= $footer_top_column; $i ++ ) { register_sidebar( array( 'name' => sprintf( esc_html__( 'Footer Top %s', 'landmaster' ), $i ), 'id' => 'sidebar-footer-' . $i, 'description' => esc_html__( 'Add widgets here.', 'landmaster' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '', ) ); } } } } add_action( 'widgets_init', 'landmaster_widgets_init' ); /** * Enqueue scripts and styles. */ function landmaster_scripts() { $theme = wp_get_theme( get_template() ); wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array(), '4.0.0' ); wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.min.css', array(), '4.7.0' ); wp_enqueue_style('font-awesome5', get_template_directory_uri() . '/assets/css/font-awesome5.min.css', array(), '5.8.0' ); wp_enqueue_style( 'material-design-iconic-font', get_template_directory_uri() . '/assets/css/material-design-iconic-font.min.css', array(), '2.2.0' ); wp_enqueue_style( 'icofont', get_template_directory_uri() . '/assets/css/icofont.min.css', array(), '1.0.1' ); wp_enqueue_style( 'magnific-popup', get_template_directory_uri() . '/assets/css/magnific-popup.css', array(), '1.0.0' ); wp_enqueue_style( 'landmaster-theme', get_template_directory_uri() . '/assets/css/theme.css', array(), $theme->get( 'Version' ) ); wp_enqueue_style( 'twentytwenty', get_template_directory_uri() . '/assets/css/twentytwenty.css', array(), '2.0.0' ); wp_enqueue_style( 'animate', get_template_directory_uri() . '/assets/css/animate.css', array(), '1.0.0' ); wp_enqueue_style( 'landmaster-menu', get_template_directory_uri() . '/assets/css/menu.css', array(), $theme->get( 'Version' ) ); wp_enqueue_style( 'landmaster-style', get_stylesheet_uri() ); wp_enqueue_style( 'landmaster-google-fonts', landmaster_fonts_url() ); /* Lib JS */ wp_enqueue_script('jquery-cookie', get_template_directory_uri() . '/assets/js/jquery.cookie.js', array( 'jquery' ), '1.4.1', true); wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array( 'jquery' ), '4.0.0', true ); wp_register_script('owl-carousel', get_template_directory_uri() . '/assets/js/owl.carousel.min.js', array('jquery'), '2.2.1', true); wp_register_script('landmaster-carousel', get_template_directory_uri() . '/assets/js/cms-carousel.js', array('jquery'), $theme->get('Version'), true); wp_enqueue_script( 'nice-select', get_template_directory_uri() . '/assets/js/nice-select.min.js', array( 'jquery' ), 'all', true ); wp_enqueue_script( 'match-height', get_template_directory_uri() . '/assets/js/match-height-min.js', array( 'jquery' ), '1.0.0', true ); wp_enqueue_script( 'landmaster-sidebar-scroll-fixed', get_template_directory_uri() . '/assets/js/sidebar-scroll-fixed.js', array( 'jquery' ), '1.0.0', true ); wp_enqueue_script( 'magnific-popup', get_template_directory_uri() . '/assets/js/magnific-popup.min.js', array( 'jquery' ), '1.0.0', true ); wp_register_script( 'jquery-event-move', get_template_directory_uri() . '/assets/js/jquery.event.move.js', array( 'jquery' ), '2.0.0', true ); wp_register_script( 'jquery-twentytwenty', get_template_directory_uri() . '/assets/js/jquery.twentytwenty.js', array( 'jquery' ), '2.0.0', true ); wp_enqueue_script( 'wow', get_template_directory_uri() . '/assets/js/wow.min.js', array( 'jquery' ), '1.3.0', true ); $smoothscroll = landmaster_get_opt( 'smoothscroll', false ); if(isset($smoothscroll) && $smoothscroll) { wp_enqueue_script('landmaster-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array('jquery'), $theme->get('Version'), true); } /* Theme JS */ if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } wp_enqueue_script( 'landmaster-main', get_template_directory_uri() . '/assets/js/main.js', array( 'jquery' ), $theme->get( 'Version' ), true ); wp_enqueue_script( 'landmaster-woocommerce', get_template_directory_uri() . '/woocommerce/woocommerce.js', array( 'jquery' ), $theme->get( 'Version' ), true ); wp_localize_script( 'landmaster-main', 'main_data', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); /* * Elementor Widget JS */ // Counter Widget wp_register_script( 'cms-counter-widget-js', get_template_directory_uri() . '/elementor/js/cms-counter-widget.js', [ 'jquery' ], $theme->get( 'Version' ) ); // Newsletter Widget wp_register_script( 'cms-newsletter-widget-js', get_template_directory_uri() . '/elementor/js/cms-newsletter-widget.js', [ 'jquery' ], $theme->get( 'Version' ) ); // Countdown Time Widget wp_register_script( 'cms-countdown-time-widget-js', get_template_directory_uri() . '/elementor/js/countdown-time-widget.js', [ 'jquery' ], $theme->get( 'Version' ) ); // Progress Bar Widget wp_register_script( 'cms-progressbar-widget-js', get_template_directory_uri() . '/elementor/js/cms-progressbar-widget.js', [ 'jquery' ], $theme->get( 'Version' ) ); // Clients List Widget wp_register_script( 'cms-clients-list-widget-js', get_template_directory_uri() . '/elementor/js/cms-clients-list-widget.js', [ 'jquery' ], $theme->get( 'Version' ) ); // Teams List Widget wp_register_script( 'cms-item-carousel-js', get_template_directory_uri() . '/elementor/js/cms-item-carousel.js', [ 'jquery' ], $theme->get( 'Version' ) ); // CMS Post Carousel Widget wp_register_script( 'cms-post-carousel-widget-js', get_template_directory_uri() . '/elementor/js/cms-post-carousel-widget.js', [ 'jquery' ], $theme->get( 'Version' ) ); // Google Maps Widget $api = landmaster_get_opt('gm_api_key', 'AIzaSyC08_qdlXXCWiFNVj02d-L2BDK5qr6ZnfM'); $api_js = "https://maps.googleapis.com/maps/api/js?sensor=false&key=".$api; wp_register_script('maps-googleapis', $api_js, [], $theme->get( 'Version' )); wp_register_script('custom-gm-widget-js', get_template_directory_uri() . '/elementor/js/custom-gm-widget.js', ['maps-googleapis', 'jquery'], $theme->get( 'Version' ), true); wp_register_script('cms-post-grid-widget-js', get_template_directory_uri() . '/elementor/js/cms-post-grid-widget.js', [ 'isotope', 'jquery' ], $theme->get( 'Version' ), true); wp_register_script('cms-toggle-widget-js', get_template_directory_uri() . '/elementor/js/cms-toggle-widget.js', [ 'jquery' ], $theme->get( 'Version' ), true); wp_register_script('cms-accordion-widget-js', get_template_directory_uri() . '/elementor/js/cms-accordion-widget.js', [ 'jquery' ], $theme->get( 'Version' ), true); wp_register_script('cms-alert-widget-js', get_template_directory_uri() . '/elementor/js/cms-alert-widget.js', [ 'jquery' ], $theme->get( 'Version' ), true); } add_action( 'wp_enqueue_scripts', 'landmaster_scripts' ); /* add editor styles */ function landmaster_add_editor_styles() { add_editor_style( 'editor-style.css' ); } add_action( 'admin_init', 'landmaster_add_editor_styles' ); /* add admin styles */ function landmaster_admin_style() { $theme = wp_get_theme( get_template() ); wp_enqueue_style( 'landmaster-admin-style', get_template_directory_uri() . '/assets/css/admin.css' ); wp_enqueue_style( 'font-material', get_template_directory_uri() . '/assets/css/font-material.min.css', array(), '2.2.0' ); wp_enqueue_script('landmaster-main-admin', get_template_directory_uri() . '/assets/js/main-admin.js', array( 'jquery' ), $theme->get('Version'), true); } add_action( 'admin_enqueue_scripts', 'landmaster_admin_style' ); /** * Helper functions for this theme. */ require_once get_template_directory() . '/inc/template-functions.php'; /** * Theme options */ require_once get_template_directory() . '/inc/theme-options.php'; /** * Page options */ require_once get_template_directory() . '/inc/page-options.php'; /** * CSS Generator. */ if ( ! class_exists( 'CSS_Generator' ) ) { require_once get_template_directory() . '/inc/classes/class-css-generator.php'; } /** * Breadcrumb. */ require_once get_template_directory() . '/inc/classes/class-breadcrumb.php'; /** * Custom template tags for this theme. */ require_once get_template_directory() . '/inc/template-tags.php'; /* Load list require plugins */ require_once( get_template_directory() . '/inc/require-plugins.php' ); /* Load lib Font */ require_once get_template_directory() . '/inc/libs/fontawesome.php'; require_once get_template_directory() . '/inc/libs/materialdesign.php'; /** * Additional widgets for the theme */ require_once get_template_directory() . '/widgets/widget-getintouch.php'; require_once get_template_directory() . '/widgets/widget-project-info.php'; require_once get_template_directory() . '/widgets/widget-contact-phone.php'; require_once get_template_directory() . '/widgets/widget-contact-box.php'; require_once get_template_directory() . '/widgets/widget-brochures-download.php'; require_once get_template_directory() . '/widgets/widget-recent-posts.php'; require_once get_template_directory() . '/widgets/widget-social.php'; require_once get_template_directory() . '/widgets/class.widget-extends.php'; /** * Functions which enhance the theme by hooking into WordPress. */ require_once get_template_directory() . '/inc/extends.php'; /** * Tutorials snippet functions. You should add those to extends.php * and remove the file. */ require_once get_template_directory() . '/inc/snippets.php'; if ( ! function_exists( 'landmaster_fonts_url' ) ) : /** * Register Google fonts. * * Create your own landmaster_fonts_url() function to override in a child theme. * * @since league 1.1 * * @return string Google fonts URL for the theme. */ function landmaster_fonts_url() { $fonts_url = ''; $fonts = array(); $subsets = 'latin,latin-ext'; if ( 'off' !== _x( 'on', 'Roboto font: on or off', 'landmaster' ) ) { $fonts[] = 'Roboto:300,400,400i,500,500i,700,700i'; } if ( $fonts ) { $fonts_url = add_query_arg( array( 'family' => urlencode( implode( '|', $fonts ) ), 'subset' => urlencode( $subsets ), ), 'https://fonts.googleapis.com/css' ); } return $fonts_url; } endif; /** * Commnet Form */ function landmaster_comment_field_to_bottom( $fields ) { $comment_field = $fields['comment']; unset( $fields['comment'] ); $fields['comment'] = $comment_field; return $fields; } add_filter( 'comment_form_fields', 'landmaster_comment_field_to_bottom' ); /** * Add Template Woocommerce */ if(class_exists('Woocommerce')){ require_once( get_template_directory() . '/woocommerce/wc-function-hooks.php' ); } // Defer selected non-critical scripts to reduce Total Blocking Time. add_action('template_redirect', function () { if (is_admin()) { return; } ob_start(function ($buffer) { return preg_replace_callback( '#]*\bsrc="[^"]*(?:liquid-custom-builder/assets/js/main\.js|liquid-custom-builder/assets/js/lib/slick\.js|themes/landmaster/elementor/js/cms-post-carousel-widget\.js|themes/landmaster/elementor/js/cms-counter-widget\.js|isotope\.pkgd\.min\.js|themes/landmaster/elementor/js/cms-item-carousel\.js)[^"]*"[^>]*>#i', function ($matches) { $tag = $matches[0]; if (stripos($tag, ' defer') !== false || stripos($tag, ' async') !== false) { return $tag; } return preg_replace('/ 'https://schema.org', '@type' => 'Product', 'name' => $product->get_name(), 'description' => wp_strip_all_tags($product->get_short_description()), 'image' => wp_get_attachment_url($product->get_image_id()), 'sku' => $product->get_sku(), 'mpn' => $product->get_sku(), 'brand' => array( '@type' => 'Brand', 'name' => 'AgriBee Seeds' ), 'offers' => array( '@type' => 'Offer', 'url' => get_permalink(), 'priceCurrency' => 'INR', 'price' => $product->get_price(), 'priceValidUntil' => date('Y-m-d', strtotime('+1 year')), 'itemCondition' => 'https://schema.org/NewCondition', 'availability' => $product->is_in_stock() ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock', 'seller' => array( '@type' => 'Organization', 'name' => 'AgriBee Seeds Private Limited' ) ), 'aggregateRating' => array( '@type' => 'AggregateRating', 'ratingValue' => '4.8', 'reviewCount' => '150' ) ); // Add category if available $categories = $product->get_category_ids(); if (!empty($categories)) { $category_name = get_term($categories[0], 'product_cat')->name; $schema['category'] = $category_name; } echo '' . "\n"; } // Add FAQ Schema for product pages add_action('wp_head', 'agribee_product_faq_schema', 25); function agribee_product_faq_schema() { if (!is_product()) { return; } global $product; if (!$product) { return; } // Get product description for FAQ content $description = $product->get_description(); $short_description = $product->get_short_description(); $faq_schema = array( '@context' => 'https://schema.org', '@type' => 'FAQPage', 'mainEntity' => array( array( '@type' => 'Question', 'name' => 'What is ' . $product->get_name() . '?', 'acceptedAnswer' => array( '@type' => 'Answer', 'text' => wp_strip_all_tags($short_description ? $short_description : $description) ) ), array( '@type' => 'Question', 'name' => 'How to use ' . $product->get_name() . '?', 'acceptedAnswer' => array( '@type' => 'Answer', 'text' => 'For best results, follow the sowing instructions provided with the seed package. Contact our agricultural experts at +91 89800 89908 for personalized guidance.' ) ), array( '@type' => 'Question', 'name' => 'What is the price of ' . $product->get_name() . '?', 'acceptedAnswer' => array( '@type' => 'Answer', 'text' => 'The price of ' . $product->get_name() . ' is ₹' . $product->get_price() . '. Contact us for bulk orders and special discounts.' ) ) ) ); echo '' . "\n"; } /** * SEO Optimizer for AgriBee Seeds * * Add this to your theme's functions.php */ // 1. Optimize Title Tags add_filter('wp_title', 'agribee_optimize_title', 10, 2); function agribee_optimize_title($title, $sep = '|') { if (is_front_page()) { return 'AgriBee Seeds - Premium Agriculture Seeds Company in India | Hybrid, Vegetable, Pulses'; } if (is_product_category()) { $category = get_queried_object(); return $category->name . ' Seeds - Buy ' . $category->name . ' Seeds Online | AgriBee Seeds'; } if (is_product()) { global $product; return $product->get_name() . ' - Buy ' . $product->get_name() . ' Online | AgriBee Seeds'; } if (is_page('about')) { return 'About AgriBee Seeds - Leading Agriculture Seeds Company in India'; } if (is_page('contact')) { return 'Contact AgriBee Seeds - Get Free Agricultural Consultation'; } return $title; } // 2. Optimize Meta Descriptions add_action('wp_head', 'agribee_optimize_meta_descriptions', 1); function agribee_optimize_meta_descriptions() { if (is_front_page()) { echo '' . "\n"; echo '' . "\n"; } if (is_product_category()) { $category = get_queried_object(); echo '' . "\n"; echo '' . "\n"; } if (is_product()) { global $product; echo '' . "\n"; echo '' . "\n"; } } // 3. Add Open Graph Meta Tags add_action('wp_head', 'agribee_open_graph_meta', 5); function agribee_open_graph_meta() { if (is_front_page()) { echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; } if (is_product()) { global $product; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; } } // 4. Add Twitter Card Meta Tags add_action('wp_head', 'agribee_twitter_card_meta', 6); function agribee_twitter_card_meta() { echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; if (is_front_page()) { echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; } if (is_product()) { global $product; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; } } // 5. Add Canonical URLs add_action('wp_head', 'agribee_canonical_urls', 7); function agribee_canonical_urls() { if (is_front_page()) { echo '' . "\n"; } if (is_product_category()) { echo '' . "\n"; } if (is_product()) { echo '' . "\n"; } } // 6. Add Breadcrumb Schema add_action('wp_head', 'agribee_breadcrumb_schema', 8); function agribee_breadcrumb_schema() { if (is_front_page()) { return; } $schema = array( '@context' => 'https://schema.org', '@type' => 'BreadcrumbList', 'itemListElement' => array( array( '@type' => 'ListItem', 'position' => 1, 'item' => array( '@id' => home_url('/'), 'name' => 'Home' ) ) ) ); if (is_product_category()) { $schema['itemListElement'][] = array( '@type' => 'ListItem', 'position' => 2, 'item' => array( '@id' => get_term_link(get_queried_object()), 'name' => get_queried_object()->name ) ); } if (is_product()) { global $product; $category = get_the_terms($product->get_id(), 'product_cat'); if ($category) { $schema['itemListElement'][] = array( '@type' => 'ListItem', 'position' => 2, 'item' => array( '@id' => get_term_link($category[0]), 'name' => $category[0]->name ) ); } $schema['itemListElement'][] = array( '@type' => 'ListItem', 'position' => 3, 'item' => array( '@id' => get_permalink(), 'name' => $product->get_name() ) ); } echo '' . "\n"; } // 7. Add Organization Schema add_action('wp_head', 'agribee_organization_schema', 9); function agribee_organization_schema() { if (!is_front_page()) { return; } $schema = array( '@context' => 'https://schema.org', '@type' => 'Organization', 'name' => 'AgriBee Seeds Private Limited', 'url' => home_url('/'), 'logo' => home_url('/wp-content/uploads/2024/10/NEW_AGRIBEE-LOGO_COLOR.png'), 'description' => 'Trusted agriculture seeds company in India offering premium hybrid seeds, vegetable seeds, pulses, and oil seeds.', 'address' => array( '@type' => 'PostalAddress', 'streetAddress' => 'G1486, D Road, Kishan Gate, GIDC Metoda', 'addressLocality' => 'Rajkot', 'addressRegion' => 'Gujarat', 'postalCode' => '360021', 'addressCountry' => 'IN' ), 'contactPoint' => array( '@type' => 'ContactPoint', 'telephone' => '+918980089908', 'contactType' => 'customer service', 'areaServed' => 'IN', 'availableLanguage' => 'English' ), 'sameAs' => array( 'https://facebook.com/agribee.in', 'https://twitter.com/iagribee', 'https://instagram.com/agribee.seeds/', 'https://linkedin.com/company/agribee-seeds' ) ); echo '' . "\n"; } // 8. Optimize WooCommerce Product Titles for SEO add_filter('woocommerce_product_title', 'agribee_optimize_product_title', 10, 2); function agribee_optimize_product_title($title, $product) { // Add brand prefix if not present if (strpos($title, 'AgriBee') === false) { return 'AgriBee ' . $title; } return $title; } // 9. Add SEO-friendly Product Excerpts add_filter('woocommerce_short_description', 'agribee_optimize_short_description', 10, 1); function agribee_optimize_short_description($description) { if (empty($description)) { return $description; } // Add call-to-action if not present if (strpos($description, 'Call') === false && strpos($description, 'Contact') === false) { $description .= '

Order now or call +91 89800 89908 for bulk orders!'; } return $description; } // 10. Add Internal Linking for SEO add_action('wp_footer', 'agribee_internal_links', 20); function agribee_internal_links() { if (is_front_page()) { ?> } } /** * Image SEO Optimizer for AgriBee Seeds * * Add this to your theme's functions.php */ // 1. Add Alt Tags to WooCommerce Product Images add_filter('wp_get_attachment_image_attributes', 'agribee_optimize_image_attributes', 10, 3); function agribee_optimize_image_attributes($attr, $attachment, $size) { if (is_admin()) { return $attr; } // Get alt text from post title if empty if (empty($attr['alt'])) { $attr['alt'] = get_the_title($attachment->ID); } // Add AgriBee branding to alt text if (strpos($attr['alt'], 'AgriBee') === false && strpos($attr['alt'], 'agribee') === false) { $attr['alt'] .= ' - AgriBee Seeds'; } // Add title attribute for better SEO if (empty($attr['title'])) { $attr['title'] = $attr['alt']; } // Add loading="lazy" for better performance (except for LCP images) if (!isset($attr['loading'])) { $attr['loading'] = 'lazy'; } // Add decoding="async" for better performance if (!isset($attr['decoding'])) { $attr['decoding'] = 'async'; } return $attr; } // 2. Add Alt Tags to WooCommerce Product Gallery Images add_filter('woocommerce_product_get_image', 'agribee_optimize_product_image', 10, 6); function agribee_optimize_product_image($image, $attachment_id, $size, $attr, $placeholder, $product) { if (is_string($image) && !empty($image)) { // Add alt tag to image $alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); if (empty($alt)) { $alt = $product->get_name() . ' - AgriBee Seeds'; } // Replace alt tag in image HTML $image = preg_replace('/alt="[^"]*"/', 'alt="' . esc_attr($alt) . '"', $image); // Add title tag if missing if (strpos($image, 'title=') === false) { $title = $product->get_name() . ' - Buy Online | AgriBee Seeds'; $image = str_replace('name . ' seeds from AgriBee Seeds. High germination rate, disease resistant varieties. Free agricultural consultation. Call +91 89800 89908.

'; } return $description; } // 5. Add Alt Tags to WooCommerce Product Gallery add_filter('woocommerce_single_product_image_thumbnail_html', 'agribee_optimize_gallery_image', 10, 2); function agribee_optimize_gallery_image($html, $attachment_id) { if (is_admin()) { return $html; } // Get alt text $alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); if (empty($alt)) { global $product; if ($product) { $alt = $product->get_name() . ' - AgriBee Seeds'; } else { $alt = 'AgriBee Seeds Product Image'; } } // Add alt tag if missing if (strpos($html, 'alt=') === false) { $html = str_replace('get_image_id()); $schema = array( '@context' => 'https://schema.org', '@type' => 'ImageObject', 'contentUrl' => $image, 'license' => 'https://creativecommons.org/licenses/by/4.0/', 'acquireLicensePage' => home_url('/terms/'), 'creditText' => 'AgriBee Seeds', 'copyrightYear' => date('Y'), 'creator' => array( '@type' => 'Organization', 'name' => 'AgriBee Seeds' ) ); echo '' . "\n"; } // 7. Add Image Sitemap Support add_action('wp_head', 'agribee_image_sitemap', 20); function agribee_image_sitemap() { if (!is_product()) { return; } global $product; if (!$product) { return; } $images = array(); $images[] = wp_get_attachment_url($product->get_image_id()); // Get gallery images $gallery = $product->get_gallery_image_ids(); foreach ($gallery as $image_id) { $images[] = wp_get_attachment_url($image_id); } foreach ($images as $image_url) { echo '' . "\n"; } } /** * Internal Linking Structure for AgriBee Seeds * * Add this to your theme's functions.php */ // 1. Add Internal Links to Blog Posts add_filter('the_content', 'agribee_add_internal_links', 999); function agribee_add_internal_links($content) { if (is_admin() || !is_singular()) { return $content; } // Define internal links to add $internal_links = array( 'hybrid seeds' => array( 'url' => home_url('/product-category/hybrid-seeds/'), 'text' => 'hybrid seeds' ), 'vegetable seeds' => array( 'url' => home_url('/product-category/vegetable-seeds/'), 'text' => 'vegetable seeds' ), 'pulses seeds' => array( 'url' => home_url('/product-category/pulses-seeds/'), 'text' => 'pulses seeds' ), 'oil seeds' => array( 'url' => home_url('/product-category/oil-seeds/'), 'text' => 'oil seeds' ), 'agriculture seeds' => array( 'url' => home_url('/'), 'text' => 'agriculture seeds' ), 'seeds company' => array( 'url' => home_url('/about/'), 'text' => 'seeds company' ), 'buy seeds' => array( 'url' => home_url('/contact/'), 'text' => 'buy seeds' ), 'seed price' => array( 'url' => home_url('/contact/'), 'text' => 'seed price' ), 'contact us' => array( 'url' => home_url('/contact/'), 'text' => 'contact us' ), 'about us' => array( 'url' => home_url('/about/'), 'text' => 'about us' ) ); // Add links to content (only once per keyword) foreach ($internal_links as $keyword => $link) { $pattern = '/(?' . $keyword . '', $content, 1); } return $content; } // 2. Add Related Products Section add_action('woocommerce_after_single_product', 'agribee_related_products_seo', 20); function agribee_related_products_seo() { global $product; if (!$product) { return; } // Get product categories $categories = get_the_terms($product->get_id(), 'product_cat'); if (!$categories || is_wp_error($categories)) { return; } $category_ids = array(); foreach ($categories as $category) { $category_ids[] = $category->term_id; } // Get related products $related_products = wc_get_products(array( 'category' => array_column($categories, 'slug'), 'limit' => 4, 'exclude' => array($product->get_id()), 'orderby' => 'rand' )); if (empty($related_products)) { return; } echo ''; } // 3. Add Category Navigation Links add_action('woocommerce_before_shop_loop', 'agribee_category_navigation_seo', 5); function agribee_category_navigation_seo() { if (!is_product_category()) { return; } $current_category = get_queried_object(); // Get all product categories $categories = get_terms(array( 'taxonomy' => 'product_cat', 'hide_empty' => true, 'parent' => 0 )); if (empty($categories) || is_wp_error($categories)) { return; } echo '
'; echo '

Our Seed Categories

'; echo ''; echo '
'; } // 4. Add Breadcrumbs for SEO add_action('wp_head', 'agribee_breadcrumbs_seo', 10); function agribee_breadcrumbs_seo() { if (is_front_page()) { return; } $breadcrumbs = array(); $breadcrumbs[] = array( 'name' => 'Home', 'url' => home_url('/') ); if (is_product_category()) { $category = get_queried_object(); $breadcrumbs[] = array( 'name' => $category->name, 'url' => get_term_link($category) ); } if (is_product()) { global $product; $categories = get_the_terms($product->get_id(), 'product_cat'); if ($categories && !is_wp_error($categories)) { $breadcrumbs[] = array( 'name' => $categories[0]->name, 'url' => get_term_link($categories[0]) ); } $breadcrumbs[] = array( 'name' => $product->get_name(), 'url' => get_permalink() ); } if (is_page()) { $breadcrumbs[] = array( 'name' => get_the_title(), 'url' => get_permalink() ); } if (is_single()) { $breadcrumbs[] = array( 'name' => get_the_title(), 'url' => get_permalink() ); } echo ''; } // 5. Add Internal Links in Footer add_action('wp_footer', 'agribee_footer_internal_links', 25); function agribee_footer_internal_links() { if (is_admin()) { return; } $footer_links = array( 'Hybrid Seeds' => home_url('/product-category/hybrid-seeds/'), 'Vegetable Seeds' => home_url('/product-category/vegetable-seeds/'), 'Pulses Seeds' => home_url('/product-category/pulses-seeds/'), 'Oil Seeds' => home_url('/product-category/oil-seeds/'), 'About Us' => home_url('/about/'), 'Contact Us' => home_url('/contact/') ); echo ''; } /** * SEO Blog Template for AgriBee Seeds * * Create blog posts with this template for better SEO */ // Blog Post Ideas for SEO $blog_posts = array( array( 'title' => 'Top 10 Hybrid Seeds for Gujarat Farmers in 2024', 'slug' => 'top-10-hybrid-seeds-gujarat-farmers-2024', 'meta_description' => 'Discover the top 10 hybrid seeds for Gujarat farmers in 2024. High-yielding, disease-resistant varieties perfect for Gujarat\'s climate. Buy from AgriBee Seeds.', 'keywords' => 'hybrid seeds Gujarat, top hybrid seeds 2024, Gujarat farming, agriculture seeds', 'content' => 'Gujarat is known for its diverse agricultural landscape. Choosing the right hybrid seeds can significantly impact your crop yield...' ), array( 'title' => 'Best Vegetable Seeds for Gujarat Climate', 'slug' => 'best-vegetable-seeds-gujarat-climate', 'meta_description' => 'Find the best vegetable seeds for Gujarat\'s climate. Tomato, chili, brinjal, okra varieties optimized for Gujarat farming. Order from AgriBee Seeds.', 'keywords' => 'vegetable seeds Gujarat, Gujarat climate seeds, tomato seeds, chili seeds', 'content' => 'Gujarat\'s climate is ideal for growing a wide variety of vegetables. Here are the best vegetable seeds for different regions...' ), array( 'title' => 'Pulses Farming in Gujarat: Complete Guide', 'slug' => 'pulses-farming-gujarat-complete-guide', 'meta_description' => 'Complete guide to pulses farming in Gujarat. Learn about groundnut, pigeon pea, chickpea cultivation. Get expert tips from AgriBee Seeds.', 'keywords' => 'pulses farming Gujarat, groundnut cultivation, pigeon pea farming, chickpea seeds', 'content' => 'Pulses are an important part of Gujarat\'s agriculture. This guide covers everything you need to know about pulses farming...' ), array( 'title' => 'Oil Seeds Cultivation in Gujarat: Mustard, Sesame, Sunflower', 'slug' => 'oil-seeds-cultivation-gujarat', 'meta_description' => 'Learn about oil seeds cultivation in Gujarat. Mustard, sesame, sunflower farming tips and best seed varieties. Contact AgriBee Seeds.', 'keywords' => 'oil seeds Gujarat, mustard farming, sesame cultivation, sunflower seeds', 'content' => 'Oil seeds are profitable crops in Gujarat. Here\'s how to cultivate mustard, sesame, and sunflower...' ), array( 'title' => 'How to Choose the Right Seeds for Your Farm', 'slug' => 'how-to-choose-right-seeds-farm', 'meta_description' => 'Learn how to choose the right seeds for your farm. Factors to consider, seed quality testing, and expert advice from AgriBee Seeds.', 'keywords' => 'choose right seeds, seed selection, farm seeds, agriculture tips', 'content' => 'Choosing the right seeds is crucial for successful farming. Here are the key factors to consider...' ), array( 'title' => 'Gujarat Agriculture Calendar: When to Sow What', 'slug' => 'gujarat-agriculture-calendar-sow-what', 'meta_description' => 'Complete Gujarat agriculture calendar. Learn when to sow different crops in Gujarat. Kharif, Rabi, and Zaid season guide from AgriBee Seeds.', 'keywords' => 'Gujarat agriculture calendar, sowing schedule, Kharif crops, Rabi crops', 'content' => 'Gujarat has three main agricultural seasons. Here\'s a complete calendar of when to sow different crops...' ) ); // Schema for Blog Posts function agribee_blog_schema($post) { $schema = array( '@context' => 'https://schema.org', '@type' => 'BlogPosting', 'mainEntityOfPage' => array( '@type' => 'WebPage', '@id' => get_permalink($post->ID) ), 'headline' => get_the_title($post->ID), 'description' => wp_strip_all_tags(get_the_excerpt($post->ID)), 'image' => get_the_post_thumbnail_url($post->ID, 'full'), 'author' => array( '@type' => 'Organization', 'name' => 'AgriBee Seeds', 'url' => home_url('/') ), 'publisher' => array( '@type' => 'Organization', 'name' => 'AgriBee Seeds', 'logo' => array( '@type' => 'ImageObject', 'url' => home_url('/wp-content/uploads/2024/10/NEW_AGRIBEE-LOGO_COLOR.png') ) ), 'datePublished' => get_the_date('c', $post->ID), 'dateModified' => get_the_modified_date('c', $post->ID) ); return $schema; } // Add Blog Schema to Posts add_action('wp_head', 'agribee_add_blog_schema', 20); function agribee_add_blog_schema() { if (!is_single()) { return; } global $post; if (!$post) { return; } $schema = agribee_blog_schema($post); echo '' . "\n"; } // Add Blog Post Meta Description add_action('wp_head', 'agribee_blog_meta_description', 15); function agribee_blog_meta_description() { if (!is_single()) { return; } global $post; if (!$post) { return; } $excerpt = wp_strip_all_tags(get_the_excerpt($post->ID)); $excerpt = substr($excerpt, 0, 160); echo '' . "\n"; echo '' . "\n"; } // Add Blog Post Internal Links add_filter('the_content', 'agribee_add_blog_internal_links', 998); function agribee_add_blog_internal_links($content) { if (is_admin() || !is_single()) { return $content; } // Add related products link at the end $related_links = ''; $content .= $related_links; return $content; } // Create Blog Post Function function agribee_create_blog_post($post_data) { // This function would be used to programmatically create blog posts // For now, it's a template for manual creation $post_id = wp_insert_post(array( 'post_title' => $post_data['title'], 'post_name' => $post_data['slug'], 'post_content' => $post_data['content'], 'post_status' => 'publish', 'post_type' => 'post', 'meta_input' => array( '_yoast_wpseo_metadesc' => $post_data['meta_description'], '_yoast_wpseo_focuskw' => $post_data['keywords'] ) )); return $post_id; } https://agribee.in/post-sitemap.xml 2026-08-09T05:49:41+00:00 https://agribee.in/page-sitemap.xml 2026-08-09T06:28:45+00:00 https://agribee.in/portfolio-sitemap.xml 2025-01-06T04:19:27+00:00 https://agribee.in/service-sitemap.xml 2024-12-03T04:42:15+00:00 https://agribee.in/footer-sitemap.xml 2026-04-07T06:12:14+00:00 https://agribee.in/product-sitemap.xml 2026-07-14T06:38:04+00:00 https://agribee.in/category-sitemap.xml 2026-08-09T05:49:41+00:00 https://agribee.in/post_tag-sitemap.xml 2026-07-14T05:25:47+00:00 https://agribee.in/portfolio-category-sitemap.xml 2025-01-06T04:18:57+00:00 https://agribee.in/product_cat-sitemap.xml 2026-07-14T06:38:04+00:00 https://agribee.in/product_tag-sitemap.xml 2026-07-14T06:38:04+00:00 https://agribee.in/crops-sitemap.xml 2026-08-08T04:20:35+00:00 https://agribee.in/local-sitemap.xml 2024-11-27T15:03:15+00:00