Itemlistelement Error...

Discussion in 'Programming' started by McCoy, Dec 2, 2021.

  1. #1
    I'm getting itemlistelement error on category page. How can I do it?
    
    <div class="breadcrumb" itemscope="" itemtype="https://schema.org/BreadcrumbList">
    <a href="<?php bloginfo('url'); ?>">Anasayfa</a>
    <?php
        $bu_kategori = get_category(get_query_var('cat'));
      
            $parent = $bu_kategori->category_parent;
            $breadDizi = array();
        do{
        if ( $parent != 0) {
            $ust_kategori = get_category($parent);
            $breadDizi[] = array(
                "term_id" => get_category_link($ust_kategori->term_id),
                "name" => $ust_kategori->name,
            );
            $parent = $ust_kategori->category_parent;
        }
    
        }while($parent > 0);
    
        $newBread = array_reverse($breadDizi, true);
        foreach ($newBread as $value) {
    ?>
        <span aria-label="breadcrumb separator">/</span>
        <a href="<?=$value["term_id"]?>" title="<?=$value["name"]?>"><?=$value["name"]?></a>
    <?php
        }
    ?>
            <span aria-label="breadcrumb separator">/</span>  
            <?=$bu_kategori->name?>
    </div>
    
    PHP:

     
    Last edited by a moderator: Dec 2, 2021
    McCoy, Dec 2, 2021 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    That error typically occurs when you have an invalid list in some HTML you're trying to read in. I don't see any such markup / html being READ... are you referring to the output from this being read by something else? If so, are the parent elements of these span and anchors a UL, OL, or DL?

    All that said, the willy nilly enter/exit of PHP is doing you no favors, if the title is the same as the content of a tag you shouldn't be setting the title, per-element schema is usually an indication of bad coding practices and/or non-semantic markup, and it looks like your "breadcrumb separator" span might be doing the job of generated content in the CSS.

    Gah, I'm so out of touch on turdpress commands, I can't make enough sense of that to make a rewrite. Or at least, I assume that's turdpress.
     
    deathshadow, Dec 3, 2021 IP
  3. Jameswalter

    Jameswalter Peon

    Messages:
    5
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    3
    #3
    That is most likely to be a structured data issue with your breadcrumbs. Typically the structured data is added by your theme.
     
    Jameswalter, Aug 17, 2022 IP