Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Further update, the hatom author & updated errors have indeed cleaned themselves up in the google console structured data.

    Update – I don’t know why the one page wasn’t working on the structured data tool originally, when I went to check again later they were all working, so even better!

    I seem to have gotten rid of the extra text line appearing at the bottom of the pages by making two changes to the functions.php code posted by Luke above. First I added this bit found in the second section of that code:

    style=”display:none;visibility:hidden;”

    to the corresponding location in the first section. Then I added these bits from the second section:

    is_home() ||
    || is_archive()

    to the corresponding locations in the first section as well.

    So that whole piece of code then now looks like this:

    /* Fix “Missing Author” and “Missing Updated” issue – START */
    add_filter( ‘the_content’, ‘custom_author_code’);
    function custom_author_code($content) {
    if (is_home() || is_singular() || is_single() || is_archive()) {
    return $content .
    ‘<div class=”hatom-extra” style=”display:none;visibility:hidden;”><span class=”title”>’. get_the_title() .'</span> was last updated <span class=”updated”> ‘. get_the_modified_time(‘F jS, Y’) .'</span> by <span class=”author vcard”><span class=”fn”>’. get_the_author() .'</span></span></div>’ ;
    } else {
    return $content;
    }
    }
    /* Fix “Missing Author” and “Missing Updated” issue – END */

    /* Fix “Missing Entry Title” issue – START */
    //add hatom data
    function add_suf_hatom_data($content) {
    $t = get_the_modified_time(‘F jS, Y’);
    $author = get_the_author();
    $title = get_the_title();
    if (is_home() || is_singular() || is_archive() ) {
    $content .= ‘<div class=”hatom-extra” style=”display:none;visibility:hidden;”><span class=”entry-title”>’.$title.'</span> was last modified: <span class=”updated”> ‘.$t.'</span> by <span class=”author vcard”><span class=”fn”>’.$author.'</span></span></div>’;
    }
    return $content;
    }
    add_filter(‘the_content’, ‘add_suf_hatom_data’);
    /* Fix “Missing Entry Title” issue – END */

    As noted above, I am no coder so use at your own risk & I probably broke something else that I just haven’t noticed yet, but my fingers are crossed that this has done the trick:)

    Thanks again Luke!!!

    Thank you Luke!!!

    This is the best result I’ve had so far from trying numerous bits of code (I am far from being a competent coder myself, but I can cut & paste ok and I’m starting to slowly absorb a few whiffs of what does what).

    Using the Google structured data testing tool, your instructions seem to have added the author/updated fields to all but one of my pages. I’ll poke around later to try to figure out why the last one hasn’t been fixed.

    The code has also however appended another line to the bottom of each page – along the lines of “Services was last updated by Al” where ‘services’ is the name of the page and ‘Al’ is the author.

    Site is handyal.ca btw.

    Anyway, this is clearly the best step forward so far so thanks again Luke!!!

    Same here … have searched & tried many bits of code to fix this error, all to no avail:( Also considering scrapping all the work done on this theme so far and starting over. I’m surprised it’s so hard to find a fix for such a popular base theme.

Viewing 4 replies - 1 through 4 (of 4 total)