Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1151245
    Patrick Rosemeyer
    Participant

    Hi Guys,

    I have the same problem with my product page how like this post. The post is for integrety stack but I’m using the icon stack. I want to change the code in icon.php in childtheme/functions/icon.php but it don’t works. I get the follow errors in structured data testing tool (See here ).

    Can you help me to solve this problem! And how can I add new schema.org in the x-theme e.g breadcrumbs and categories.

    Thank you in advanced for your support

    Patrick

    #1151249
    Rad
    Moderator

    Hi Patrick,

    Thanks for writing in.

    You can only override template files into your child theme. What you’re trying to edit is a function file and not a template file. Overriding a function is different, you just need to re-declare the same function on child theme’s functions.php and not by copying the whole file.

    Would you mind providing more details of what you’re trying to apply in icon.php?

    Thanks!

    #1151253
    Patrick Rosemeyer
    Participant

    Hi Rad,

    thank you for your fast reply! I want to implement the correct markup for schema.org for reviews, breadcrumbs and categories. I changed the same how like described in the post this post.

    In my icon.php I have changed this:

    <li id="li-comment-<?php comment_ID(); ?>" itemprop="review" itemscope itemtype="https://schema.org/Rating" <?php comment_class(); ?>>
          <?php $comment_reply = ( ! x_is_product() ) ? '<div class="x-reply">' . get_comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply<span class="comment-reply-link-after"><i class="x-icon-reply" data-x-icon=""></i></span>', '__x__' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ) . '</div>' : ''; ?>
          <?php
          printf( '<div class="x-comment-img">%1$s %2$s %3$s</div>',
            '<span class="avatar-wrap cf">' . get_avatar( $comment, 120 ) . '</span>',
            ( $comment->user_id === $post->post_author ) ? '<span class="bypostauthor">' . __( 'Post<br>Author', '__x__' ) . '</span>' : '',
            $comment_reply
          );
          ?>
          <article id="comment-<?php comment_ID(); ?>" class="comment">
            <header class="x-comment-header">
              <?php
              printf( '<cite class="x-comment-author" itemprop="author">%1$s</cite>',
                get_comment_author_link()
              );
              if ( x_is_product() && get_option( 'woocommerce_enable_review_rating' ) == 'yes' ) : ?> 
                <div class="star-rating-container">
                  <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo sprintf( __( 'Rated %d out of 5', '__x__' ), $rating ) ?>">
                    <span style="width:<?php echo ( intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ) / 5 ) * 100; ?>%"><strong itemprop="ratingValue"><?php echo intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?></strong> <?php _e( 'out of 5', '__x__' ); ?></span>
                  </div>
                </div>
              <?php endif;
              printf( '<div><a href="%1$s" class="x-comment-time"><time itemprop="datePublished" datetime="%2$s">%3$s</time></a></div>',
                esc_url( get_comment_link( $comment->comment_ID ) ),
                get_comment_time( 'c' ),
                $comment_time
              );
              edit_comment_link( __( '<i class="x-icon-edit" data-x-icon=""></i> Edit', '__x__' ) );
              ?>
            </header>
            <?php if ( '0' == $comment->comment_approved ) : ?>
              <p class="x-comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', '__x__' ); ?></p>
            <?php endif; ?>
            <section class="x-comment-content" itemprop="description">
              <?php comment_text(); ?>
            </section>
          </article>
        <?php
            break;
        endswitch;
    
      }
    endif;

    But I get the follow errors from google structured data test tool here to the test.

    I hope I describe my problem better!

    Best regards from Berlin

    Patrick

    #1151277
    Rad
    Moderator

    Hi there,

    In that case, you just need to copy the code within this block

    if ( ! function_exists( 'x_icon_comment' ) ) :
    ..
    ..
    endif;

    and paste it into your child theme’s functions.php

    function x_icon_comment( $comment, $args, $depth ) {
    
        $GLOBALS['comment'] = $comment;
        switch ( $comment->comment_type ) :
          case 'pingback' :  // 1
          case 'trackback' : // 1
        ?>
        <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
          <p><?php _e( 'Pingback:', '__x__' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', '__x__' ), '<span class="edit-link">', '</span>' ); ?></p>
        <?php
            break;
          default : // 2
          GLOBAL $post;
          if ( X_WOOCOMMERCE_IS_ACTIVE ) :
            $rating = esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) );
          endif;
          if ( x_is_product() ) :
            $comment_time = sprintf( __( '%1$s', '__x__' ), get_comment_date() );
          else :
            $comment_time = sprintf( __( '%1$s at %2$s', '__x__' ), get_comment_date(), get_comment_time() );
          endif;
        ?>
        <li id="li-comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
          <?php $comment_reply = ( ! x_is_product() ) ? '<div class="x-reply">' . get_comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply<span class="comment-reply-link-after"><i class="x-icon-reply" data-x-icon=""></i></span>', '__x__' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ) . '</div>' : ''; ?>
          <?php
          printf( '<div class="x-comment-img">%1$s %2$s %3$s</div>',
            '<span class="avatar-wrap cf">' . get_avatar( $comment, 120 ) . '</span>',
            ( $comment->user_id === $post->post_author ) ? '<span class="bypostauthor">' . __( 'Post<br>Author', '__x__' ) . '</span>' : '',
            $comment_reply
          );
          ?>
          <article id="comment-<?php comment_ID(); ?>" class="comment">
            <header class="x-comment-header">
              <?php
              printf( '<cite class="x-comment-author">%1$s</cite>',
                get_comment_author_link()
              );
              if ( x_is_product() && get_option( 'woocommerce_enable_review_rating' ) == 'yes' ) : ?> 
                <div class="star-rating-container">
                  <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo sprintf( __( 'Rated %d out of 5', '__x__' ), $rating ) ?>">
                    <span style="width:<?php echo ( intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ) / 5 ) * 100; ?>%"><strong itemprop="ratingValue"><?php echo intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?></strong> <?php _e( 'out of 5', '__x__' ); ?></span>
                  </div>
                </div>
              <?php endif;
              printf( '<div><a href="%1$s" class="x-comment-time"><time datetime="%2$s">%3$s</time></a></div>',
                esc_url( get_comment_link( $comment->comment_ID ) ),
                get_comment_time( 'c' ),
                $comment_time
              );
              edit_comment_link( __( '<i class="x-icon-edit" data-x-icon=""></i> Edit', '__x__' ) );
              ?>
            </header>
            <?php if ( '0' == $comment->comment_approved ) : ?>
              <p class="x-comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', '__x__' ); ?></p>
            <?php endif; ?>
            <section class="x-comment-content">
              <?php comment_text(); ?>
            </section>
          </article>
        <?php
            break;
        endswitch;
    
      }

    Then do the customization you wish to apply on that code.

    Thanks!

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