' . $content);
// $xpath = new DOMXPath($dom);
// // Get all questions & answers from your accordion
// $questions = $xpath->query("//*[contains(@class, 'accordion-button')]");
// $answers = $xpath->query("//*[contains(@class, 'accordion-body')]");
// if ($questions->length === 0 || $answers->length === 0) return;
// $schema = [
// "@context" => "https://schema.org",
// "@type" => "FAQPage",
// "mainEntity" => []
// ];
// for ($i = 0; $i < $questions->length; $i++) {
// $question = trim($questions[$i]->textContent);
// $answer = isset($answers[$i]) ? trim($answers[$i]->textContent) : '';
// if (!$question || !$answer) continue;
// $schema["mainEntity"][] = [
// "@type" => "Question",
// "name" => wp_strip_all_tags($question),
// "acceptedAnswer" => [
// "@type" => "Answer",
// "text" => wp_strip_all_tags($answer)
// ]
// ];
// }
// if (!empty($schema["mainEntity"])) {
// echo '';
// }
// }
// // end here
// /* ===============================
// DISABLE YOAST SCHEMA (ONLY PRODUCT CATEGORY)
// =============================== */
// add_filter('wpseo_json_ld_output', function ($data) {
// if (is_product_category()) {
// return false;
// }
// return $data;
// }, 10);
// /* ===============================
// FINAL CLEAN CATEGORY SCHEMA
// =============================== */
// add_action('wp_head', function () {
// if (!is_product_category()) return;
// $term = get_queried_object();
// if (!$term) return;
// $category_url = get_term_link($term);
// $category_name = $term->name;
// /* =========================
// 1. BREADCRUMB
// ========================= */
// $breadcrumb = [
// "@context" => "https://schema.org",
// "@type" => "BreadcrumbList",
// "@id" => $category_url . "#breadcrumb",
// "itemListElement" => []
// ];
// $position = 1;
// $breadcrumb["itemListElement"][] = [
// "@type" => "ListItem",
// "position" => $position++,
// "name" => "Home",
// "item" => home_url('/')
// ];
// $ancestors = array_reverse(get_ancestors($term->term_id, 'product_cat'));
// foreach ($ancestors as $parent_id) {
// $parent = get_term($parent_id, 'product_cat');
// if ($parent && !is_wp_error($parent)) {
// $breadcrumb["itemListElement"][] = [
// "@type" => "ListItem",
// "position" => $position++,
// "name" => $parent->name,
// "item" => get_term_link($parent)
// ];
// }
// }
// $breadcrumb["itemListElement"][] = [
// "@type" => "ListItem",
// "position" => $position++,
// "name" => $category_name,
// "item" => $category_url
// ];
// echo '';
// /* =========================
// 2. COLLECTION PAGE (SUBCATEGORIES)
// ========================= */
// $collection = [
// "@context" => "https://schema.org",
// "@type" => "CollectionPage",
// "@id" => $category_url,
// "url" => $category_url,
// "name" => $category_name,
// "hasPart" => []
// ];
// /* =========================
// 3. ITEM LIST
// ========================= */
// $itemList = [
// "@context" => "https://schema.org",
// "@type" => "ItemList",
// "@id" => $category_url . "#list",
// "name" => $category_name . " Listing",
// "itemListElement" => []
// ];
// $position = 1;
// $seen = [];
// /* ===== CHECK CHILD CATEGORIES ===== */
// $children = get_terms([
// 'taxonomy' => 'product_cat',
// 'parent' => $term->term_id,
// 'hide_empty' => true
// ]);
// if (!empty($children) && !is_wp_error($children)) {
// foreach ($children as $child) {
// $child_url = get_term_link($child);
// // Collection structure
// $collection["hasPart"][] = [
// "@type" => "CollectionPage",
// "name" => $child->name,
// "url" => $child_url
// ];
// // ItemList
// $itemList["itemListElement"][] = [
// "@type" => "ListItem",
// "position" => $position++,
// "@id" => $child_url,
// "url" => $child_url,
// "name" => $child->name
// ];
// }
// } else {
// /* ===== PRODUCTS (DEDUP + CLEAN) ===== */
// $products = new WP_Query([
// 'post_type' => 'product',
// 'posts_per_page' => 20,
// 'tax_query' => [
// [
// 'taxonomy' => 'product_cat',
// 'field' => 'term_id',
// 'terms' => $term->term_id,
// ]
// ]
// ]);
// if ($products->have_posts()) {
// while ($products->have_posts()) {
// $products->the_post();
// $url = get_permalink();
// if (in_array($url, $seen)) continue;
// $seen[] = $url;
// $itemList["itemListElement"][] = [
// "@type" => "ListItem",
// "position" => $position++,
// "@id" => $url,
// "url" => $url,
// "name" => get_the_title()
// ];
// }
// wp_reset_postdata();
// }
// }
// /* PRINT COLLECTION */
// echo '';
// /* PRINT ITEM LIST */
// if (!empty($itemList["itemListElement"])) {
// $itemList["numberOfItems"] = count($itemList["itemListElement"]);
// echo '';
// }
// }, 1);
// add_filter('wpseo_schema_breadcrumb', function($data) {
// if (isset($data['itemListElement'])) {
// foreach ($data['itemListElement'] as $key => $item) {
// // Agar item missing hai toh add karo
// if (empty($item['item']) && !empty($item['name'])) {
// // Current page URL set karo
// $data['itemListElement'][$key]['item'] = get_permalink();
// }
// }
// }
// return $data;
// });
// add_filter('wpseo_schema_graph_pieces', function ($pieces) {
// foreach ($pieces as $piece) {
// if ($piece instanceof \Yoast\WP\SEO\Generators\Schema\Person) {
// add_filter('wpseo_schema_person', function ($data) {
// if (empty($data['url'])) {
// $data['url'] = home_url('/about-us/'); // 👉 author page URL
// }
// return $data;
// });
// }
// }
// return $pieces;
// });
Warning: Cannot modify header information - headers already sent by (output started at /home/u257032506/domains/jcblagri.com/public_html/wp-content/themes/jcbl-agri-tools-child/functions.php:1090) in /home/u257032506/domains/jcblagri.com/public_html/wp-includes/pluggable.php on line 1531
Warning: Cannot modify header information - headers already sent by (output started at /home/u257032506/domains/jcblagri.com/public_html/wp-content/themes/jcbl-agri-tools-child/functions.php:1090) in /home/u257032506/domains/jcblagri.com/public_html/wp-includes/pluggable.php on line 1534