• Hi, I use the Pinnacle theme. I have disabled the visible post date, but Pinnacle still outputs this publication date in the page source.

    Google is selecting this old date in search results. Is there a Pinnacle PHP hook or filter that will prevent this element from being generated on individual posts?

    I need to remove only this theme-generated date from the rendered HTML. I still want datePublished retained in Article JSON-LD schema, and I do not want to hide it with CSS.

Viewing 1 replies (of 1 total)
  • Hi @caitriona1,

    Happy to help.

    There’s no built-in Pinnacle filter to prevent this datePublished element from being generated on individual posts.

    As a workaround, if you are using a child theme, you can create templates/entry-meta-subhead.php in your child theme with this content, which deletes the date span:

    <div class="subhead">
    <span class="postauthortop author vcard">
    <?php echo __('by', 'pinnacle'); ?> <span itemprop="author"><a href="<?php echo esc_attr(get_author_posts_url(get_the_author_meta('ID'))); ?>" class="fn" rel="author"><?php echo get_the_author() ?></a></span>
    </span>
    <span class="postcommentscount"><?php echo __('with', 'pinnacle'); ?>
    <a href="<?php the_permalink();?>#post_comments"><?php comments_number(); ?></a>
    </span>
    </div>

    If you’re using a code snippets plugin instead, you can use this snippet to strips out the date span:

    add_action( 'template_redirect', function() {
    if ( is_singular( 'post' ) ) {
    ob_start( function( $html ) {
    return preg_replace(
    '/<span class="updated postdate">.*?itemprop="datePublished".*?<\/span>\s*<\/span>/s',
    '',
    $html
    );
    } );
    }
    } );

    I hope this helps.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.