Removing post date from google snippet?

  • Starsoul

    #7862

    Hello,

    i have a blog with many walkthrough and hints for videogames. But if in the snippet in the google search is shown the posting date, the users could think this hints are outdated, but they dont.

    Is there a posibility to show the date onto the blog and the post but not in the google snippet? I have tried a few things with javascript i found on the web but with graphene i have my problems on this topic.

    Can someone help me please?

    Admin

    Syahir Hakim

    #39570

    You can override the theme’s function that generates the code for the date. Do you have a child theme already implemented?

    Starsoul

    #39571

    Hello Hakim,

    thanks for your fast reply. I use no child theme. I use the original graphene theme and functions. Any suggestions?

    Admin

    Syahir Hakim

    #39572

    You would need to create a child theme first then. Here’s a guide:

    http://docs.graphene-theme.com/Customisation_using_a_child_theme

    Starsoul

    #39573

    Thank you – and when i created the child theme – what should i change in comparsion to the original theme?

    Admin

    Syahir Hakim

    #39574

    When you’ve created a child theme, create a functions.php file inside your child theme. Then, add this code into that file:

    <?php
    /**
    * Displays the date. Replaces Graphene's function to remove date from Google rich HTML snippet.
    */
    function graphene_post_date( $id = '' ){

    if ( ! $id ) {
    global $post;
    $id = $post->ID;
    }

    if ( ! graphene_should_show_date() ) return;

    global $graphene_settings;
    $style = graphene_post_date_setting( $id, 'post_date_display' );

    if ( stristr( $style, 'icon' ) ) :
    ?>
    <div class="date alpha <?php if ( $style == 'icon_plus_year' ) echo 'with-year'; ?>">
    <p class="default_date">
    <span class="month"><?php the_time( 'M' ); ?></span>
    <span class="day"><?php the_time( 'd' ) ?></span>
    <?php if ( $style == 'icon_plus_year' ) : ?>
    <span class="year"><?php the_time( 'Y' ); ?></span>
    <?php endif; ?>
    </p>
    <?php do_action( 'graphene_post_date' ); ?>
    </div>
    <?php
    endif;

    if ( $style == 'text' ) :
    ?>
    <p class="post-date-inline">
    <?php the_time( get_option( 'date_format' ) ); ?>
    <?php do_action( 'graphene_post_date' ); ?>
    </p>
    <?php
    endif;
    }

Viewing 6 posts - 1 through 6 (of 6 total)

  • You must be logged in to reply to this topic.