Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1060844
    flyingkiwi
    Participant

    Hi,

    I have just added the following code to my childs functions.php to fix the missing Author & Updated hentry error issues

    add_filter( 'the_content', 'custom_author_code');
    
    function custom_author_code($content) {
       if (is_singular() || is_single()) {
          return $content . 
          '<div class="hatom-extra"><span class="title">'. get_the_title() .'</span> was last modified: <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;
       }
    }

    but now my blog posts excerpts are showing “#### was last modified: ##### by #####” instead of the standard excerpt that should appear.

    How I can get the default excerpts back but keep the hentry errors resolved? I really don’t want to have to create custom excerpts for each post..

    Is it possible to put the hentry output into the footer or something?

    Site: poolcarepro.com.au

    Tom

    #1060867
    Rad
    Moderator

    Hi there,

    Thanks for posting in.

    The the_content is a content filter, anything you add within will be displayed as content. Adding hentry will not fix the issue, it should be added to the area where it’s missing. For example, if it’s missing within posts loop in the carousel, then it should be added within the loop of the carousel.

    Adding it anywhere will not fix it. What’s the error you’re having with hentry and what location?

    Thanks!

    #1060909
    flyingkiwi
    Participant

    Hi,

    Please see the attached screenshot from my google webmaster tools.

    I’ve been reading lots of forum posts about the missing hentry data issue with X theme and used the code snippet as suggested in other posts.
    The above in my functions.php and `.hatom-extra {
    display: none;
    }` in my child .css – it works and adds the missing fields that google requires while hiding the ugly update line from the bottom my pages.

    Problem is that it’s now screwing with my blog excerpts…

    Is there another way of tackling this problem to get the best of both worlds?

    Tom

    #1060934
    Paul R
    Moderator

    Hi Tom,

    You need to add it to your recent posts shortcode but I can see you have already modified it.

    Can you share to us the entire code that is in your child theme’s functions.php file.

    Thanks

    #1060942
    flyingkiwi
    Participant
    <?php
    
    // =============================================================================
    // FUNCTIONS.PHP
    // -----------------------------------------------------------------------------
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================
    
    // =============================================================================
    // TABLE OF CONTENTS
    // -----------------------------------------------------------------------------
    //   01. Enqueue Parent Stylesheet
    //   02. Additional Functions
    // =============================================================================
    
    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
    
    // Additional Functions
    // =============================================================================
    
    // Supporting Contact form 7 date field in Firefox
    // =============================================================================
    add_filter( 'wpcf7_support_html5_fallback', '__return_true' );
    // =============================================================================
    
    function x_shortcode_recent_posts_v2code( $atts ) {
      extract( shortcode_atts( array(
        'id'          => '',
        'class'       => '',
        'style'       => '',
        'type'        => 'post',
        'count'       => '',
        'category'    => '',
        'enable_excerpt' => '',
        'offset'      => '',
        'orientation' => '',
        'no_image'    => '',
        'fade'        => ''
      ), $atts, 'x_recent_posts' ) );
    
      $allowed_post_types = apply_filters( 'cs_recent_posts_post_types', array( 'post' => 'post' ) );
      $type = ( isset( $allowed_post_types[$type] ) ) ? $allowed_post_types[$type] : 'post';
    
      $id            = ( $id          != ''          ) ? 'id="' . esc_attr( $id ) . '"' : '';
      $class         = ( $class       != ''          ) ? 'x-recent-posts cf ' . esc_attr( $class ) : 'x-recent-posts cf';
      $style         = ( $style       != ''          ) ? 'style="' . $style . '"' : '';
      $count         = ( $count       != ''          ) ? $count : 3;
      $category      = ( $category    != ''          ) ? $category : '';
      $category_type = ( $type        == 'post'      ) ? 'category_name' : 'portfolio-category';
      $offset        = ( $offset      != ''          ) ? $offset : 0;
      $orientation   = ( $orientation != ''          ) ? ' ' . $orientation : ' horizontal';
      $no_image      = ( $no_image    == 'true'      ) ? $no_image : '';
      $fade          = ( $fade        == 'true'      ) ? $fade : 'false';
      $enable_excerpt = ( $enable_excerpt == 'true'      ) ? true : false;
    
      $js_params = array(
        'fade' => ( $fade == 'true' )
      );
    
      $data = cs_generate_data_attributes( 'recent_posts', $js_params );
    
      $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} {$data} data-fade=\"{$fade}\" >";
    
        $q = new WP_Query( array(
          'orderby'          => 'date',
          'post_type'        => "{$type}",
          'posts_per_page'   => "{$count}",
          'offset'           => "{$offset}",
          "{$category_type}" => "{$category}"
        ) );
    
        if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();
    
          if ( $no_image == 'true' ) {
            $image_output       = '';
            $image_output_class = 'no-image';
          } else {
            $image              = wp_get_attachment_image_src( get_post_thumbnail_id(), 'entry-cropped' );
            $bg_image           = ( $image[0] != '' ) ? ' style="background-image: url(' . $image[0] . ');"' : '';
            $image_output       = '<div class="x-recent-posts-img"' . $bg_image . '></div>';
            $image_output_class = 'with-image';
          }
    
          $output .= '<a class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"', csl18n() ), the_title_attribute( 'echo=0' ) ) ) . '">'
                     . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">'
                       . '<div class="entry-wrap">'
                         . $image_output
                         . '<div class="x-recent-posts-content">'
                           . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>'
                           . '<span class="x-recent-posts-date">' . get_the_date() . '</span>'
                              . ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . strip_tags( get_the_excerpt() ) . '</span>' : '' )
                         . '</div>'
                       . '</div>'
                     . '</article>'
                   . '</a>';
    
        endwhile; endif; wp_reset_postdata();
    
      $output .= '</div>';
    
      return $output;
    }
    
    add_action('wp_head', 'change_recent_posts_to_v2');
    
    function change_recent_posts_to_v2() {
        remove_shortcode( 'x_recent_posts' );
        add_shortcode( 'x_recent_posts', 'x_shortcode_recent_posts_v2code' );
    }
    
    // CUSTOMISING LOGIN SCREEN
    
    function my_loginCSS() {
        wp_enqueue_style('login-styles', get_stylesheet_directory_uri() . '/login/login_styles.css');
    }
    add_action('login_enqueue_scripts', 'my_loginCSS');
    
    function my_loginURL() {
        return 'http://gollins.com.au';
    }
    add_filter('login_headerurl', 'my_loginURL');
    
    function my_loginURLtext() {
        return 'Site by Gollins Web Design';
    }
    add_filter('login_headertitle', 'my_loginURLtext');
    
    function my_loginfooter() { ?>
        <p class="loginfooter">
        <a class="loginfooter" href="http://gollins.com.au">If you have any questions, please contact us at Gollins.com.au
            </a>
        </p>
    <?php }
    add_action('login_footer','my_loginfooter');
    
    // Fix "Missing Author" and "Missing Updated" issue - START
    add_filter( 'the_content', 'custom_author_code');
    
    function custom_author_code($content) {
       if (is_singular() || is_single()) {
          return $content . 
          '<div class="hatom-extra"><span class="title">'. get_the_title() .'</span> was last modified: <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
    #1060950
    Rue Nel
    Moderator

    Hello There,

    Please update the custom author block of code and use this instead:

    // Fix "Missing Author" and "Missing Updated" issue - START
    add_filter( 'the_content', 'custom_author_code');
    
    function custom_author_code($content) {
       if ( is_single() ) {
          return $content . 
          '<div class="hatom-extra"><span class="title">'. get_the_title() .'</span> was last modified: <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

    The code will make sure that the author and updated information will only appear in single blog posts only.
    Hope this helps. Kindly let us know.

    #1061123
    flyingkiwi
    Participant

    That has fixed the issue of the blog excerpts not showing but leaves me with hentry issues on pages still..

    The Posts are ok now but all the Pages still have the hentry errors of missing author and date. A page like https://poolcarepro.com.au/category/news/ has 10+ errors.

    Reading around I’ve found some information on the topic you might be able to use to help..

    From a support post on wordpress.org:
    The solution for Hentry issue is by adding the rich data snippets to each and every page that gives a listing of the posts (like search listing, author page, posts by month, blogs by category etc..) and on the post detail page.

    And the solution provided:
    First create the following function in your Themes >> Includes >> theme_function.php

    function render_rich_snippets_for_pages( $title_tag = TRUE, $author_tag = TRUE, $updated_tag = TRUE ) {
    global $smof_data;
    
    $html = '';
    
    if( ! $smof_data['disable_date_rich_snippet_pages'] ) {
    
    if( $title_tag ) {
    $html = '<span class="entry-title" style="display: none;">' . get_the_title() . '</span>';
    }
    
    if( $author_tag ) {
    ob_start();
    the_author_posts_link();
    $author_post_link = ob_get_clean();
    $html .= '<span class="vcard" style="display: none;"><span class="fn">' . $author_post_link . '</span></span>';
    }
    
    if( $updated_tag ) {
    $html .= '<span class="updated" style="display:none;">' . get_the_modified_time( 'c' ) . '</span>';
    }
    }
    
    return $html;
    }

    Then add the following code on pages like page.php, single.php, author.php and other pages on which you are getting this error.

    <?php echo render_rich_snippets_for_pages(); ?>
    Note: Add it in the place where the details of the blog post is fetched.

    How can I implement this on the X theme?

    I believe this should really be something that’s included by default in X theme’s code as every site created with X will be getting the hentry error problem. A lot of people have been asking for this for months now.

    Tom

    #1061137
    Rue Nel
    Moderator

    Hello Tom,

    Thank you for the clarifications! To be able to use the function you’ve got from WordPress.org and apply it in X theme, please insert this following line of code in your child theme’s functions.php file.

    
    function add_rich_snippets(){
      if( is_page() || is_single() || is_author() ) {
        echo render_rich_snippets_for_pages();
      }
    }
    add_action('x_before_the_content_end', 'render_rich_snippets_for_pages');

    We certainly appreciate the feedback! This is something we can add to our list of feature requests. This way it can be taken into consideration for future development. All of these items are discussed with our team internally and prioritized based on the amount of interest a particular feature might receive. Thanks!

    #1061144
    flyingkiwi
    Participant

    No worries!

    Am I inserting this as a replacement to the existing code or in addition to?

    #1061159
    Rue Nel
    Moderator

    Hello There,

    The code would be useful if you opted to use the code provided from WordPress.org support so that you will no longer edit page.php, single.php or author.php. The full code should be like this:

    // Render Rich Snippets for pages
    // =============================================================================
    function render_rich_snippets_for_pages( $title_tag = TRUE, $author_tag = TRUE, $updated_tag = TRUE ) {
      global $smof_data;
    
      $html = '';
    
      if( ! $smof_data['disable_date_rich_snippet_pages'] ) {
    
        if( $title_tag ) {
          $html = '<span class="entry-title" style="display: none;">' . get_the_title() . '</span>';
        }
    
        if( $author_tag ) {
          ob_start();
          the_author_posts_link();
          $author_post_link = ob_get_clean();
          $html .= '<span class="vcard" style="display: none;"><span class="fn">' . $author_post_link . '</span></span>';
        }
    
        if( $updated_tag ) {
         $html .= '<span class="updated" style="display:none;">' . get_the_modified_time( 'c' ) . '</span>';
        }
    
      }
      return $html;
    }
    // =============================================================================
    
    // Display the rich snippets in pages, single post or author archive
    // =============================================================================
    function add_rich_snippets(){
      if( is_page() || is_single() || is_author() ) {
        echo render_rich_snippets_for_pages();
      }
    }
    add_action('x_before_the_content_end', 'render_rich_snippets_for_pages');
    // =============================================================================

    Hope this helps. Please let us know how it goes.

    #1061197
    flyingkiwi
    Participant

    Ok got it..

    I’ve now got the code in functions.php but it’s not producing the hentry data anymore.. I’m back to missing author, date & title again

    #1061274
    Paul R
    Moderator

    Hi,

    Please change the recent posts shortcode in your functions.php file to this.

    
    /* Modified Recent Posts Shortcode */
    function x_shortcode_recent_posts_v2code( $atts ) {
      extract( shortcode_atts( array(
        'id'          => '',
        'class'       => '',
        'style'       => '',
        'type'        => 'post',
        'count'       => '',
        'category'    => '',
        'enable_excerpt' => '',
        'offset'      => '',
        'orientation' => '',
        'no_image'    => '',
        'fade'        => ''
      ), $atts, 'x_recent_posts' ) );
    
      $allowed_post_types = apply_filters( 'cs_recent_posts_post_types', array( 'post' => 'post' ) );
      $type = ( isset( $allowed_post_types[$type] ) ) ? $allowed_post_types[$type] : 'post';
    
      $id            = ( $id          != ''          ) ? 'id="' . esc_attr( $id ) . '"' : '';
      $class         = ( $class       != ''          ) ? 'x-recent-posts cf ' . esc_attr( $class ) : 'x-recent-posts cf';
      $style         = ( $style       != ''          ) ? 'style="' . $style . '"' : '';
      $count         = ( $count       != ''          ) ? $count : 3;
      $category      = ( $category    != ''          ) ? $category : '';
      $category_type = ( $type        == 'post'      ) ? 'category_name' : 'portfolio-category';
      $offset        = ( $offset      != ''          ) ? $offset : 0;
      $orientation   = ( $orientation != ''          ) ? ' ' . $orientation : ' horizontal';
      $no_image      = ( $no_image    == 'true'      ) ? $no_image : '';
      $fade          = ( $fade        == 'true'      ) ? $fade : 'false';
      $enable_excerpt = ( $enable_excerpt == 'true'      ) ? true : false;
    
      $js_params = array(
        'fade' => ( $fade == 'true' )
      );
    
      $data = cs_generate_data_attributes( 'recent_posts', $js_params );
    
      $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} {$data} data-fade=\"{$fade}\" >";
    
        $q = new WP_Query( array(
          'orderby'          => 'date',
          'post_type'        => "{$type}",
          'posts_per_page'   => "{$count}",
          'offset'           => "{$offset}",
          "{$category_type}" => "{$category}"
        ) );
    
        if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();
    
          if ( $no_image == 'true' ) {
            $image_output       = '';
            $image_output_class = 'no-image';
          } else {
            $image              = wp_get_attachment_image_src( get_post_thumbnail_id(), 'entry-cropped' );
            $bg_image           = ( $image[0] != '' ) ? ' style="background-image: url(' . $image[0] . ');"' : '';
            $image_output       = '<div class="x-recent-posts-img"' . $bg_image . '></div>';
            $image_output_class = 'with-image';
          }
    
          $output .= '<a class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"', csl18n() ), the_title_attribute( 'echo=0' ) ) ) . '">'
                     . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">'
                       . '<div class="entry-wrap">'
                         . $image_output
                         . '<div class="x-recent-posts-content">'
                           . '<h3 class="h-recent-posts entry-title">' . get_the_title() . '</h3>'
                           . '<span class="x-recent-posts-date date update">' . get_the_date() . '</span>'
                              . ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . strip_tags( get_the_excerpt() ) . '</span>' : '' )
                              . '<span class="vcard author" style="display:none;"><span class="fn">'. get_the_author().'</span></span>'                         
                         . '</div>'
                       . '</div>'
                     . '</article>'
                   . '</a>';
    
        endwhile; endif; wp_reset_postdata();
    
      $output .= '</div>';
    
      return $output;
    }
    
    add_action('wp_head', 'change_recent_posts_to_v2');
    
    function change_recent_posts_to_v2() {
        remove_shortcode( 'x_recent_posts' );
        add_shortcode( 'x_recent_posts', 'x_shortcode_recent_posts_v2code' );
    }
    

    Hope that helps.

    #1061347
    flyingkiwi
    Participant

    No luck.

    Still missing hentry info on all pages!

    #1061926
    Darshana
    Moderator

    Hi there,

    Thanks for writing in! Just to confirm, there’s no SEO impact from this notifications. I have copied the response from the following post since it is private (https://community.theme.co//forums/topic/seo-4/#post-303547).

    I am one of the lead persons of Themeco and want to clarify this situation. Our support team gave you help of something which originally should not be supported by us. X does not support schema markup and therefore Google is triggering these “warnings” – This has no impact on your search engine optimization nor anything else. Schema is just a markup that is optional and enabled you to structure data. Due to the fact that this problem was new to our staff they tried to help you with the issue although it’s something out of the scope of support. I hope you understand that addressing this would be a huge undertaking and outside on what we can provide and if you have any other problems or questions related to X feel free to ask me at any time.

    Thank you for understanding.

  • <script> jQuery(function($){ $("#no-reply-1060844 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>