[Support request] remove schema created by theme

Home Forums Support [Support request] remove schema created by theme

Home Forums Support remove schema created by theme

Viewing 15 posts - 16 through 30 (of 32 total)
  • Author
    Posts
  • #734773
    Tom
    Lead Developer
    Lead Developer

    The CreativeWork microdata you’re seeing there is from the WP Show Posts plugin, which doesn’t have an option to remove the microdata currently.

    #735481
    dassana

    thanks tom. but what about the other microdata elements like hcard, comment, sitenavigation element, person, hatom. how do i get rid of these.

    #736341
    Tom
    Lead Developer
    Lead Developer

    Some seems to be coming from JSON-LD, likely from a plugin you’re using.

    Some seems to be coming from custom functions you might have added. For example, do you have any post meta (author/date) functions? If so, can you share them so I can remove the microdata for you?

    Have you edited the comments file at all/added any comments related functions?

    #737239
    dassana

    thank you tom. json ld is added by yoast and wp-recipe maker plugins. i will check with them. the custom functions i have added for post meta are mentioned below. yes i have edited the customs.php in the child theme. pasted below the comments.php file code too.

    post meta functions:

    /*remove comment links*/

    if ( ! function_exists( ‘generate_comment’ ) ) {
    /**
    * Template for comments and pingbacks.
    *
    * Used as a callback by wp_list_comments() for displaying the comments.
    */
    function generate_comment( $comment, $args, $depth ) {
    $args[‘avatar_size’] = apply_filters( ‘generate_comment_avatar_size’, 50 );
    if ( ‘pingback’ == $comment->comment_type || ‘trackback’ == $comment->comment_type ) : ?>

    <li id=”comment-<?php comment_ID(); ?>” <?php comment_class(); ?>>

    <?php _e( ‘Pingback:’, ‘generatepress’ ); // WPCS: XSS OK. ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( ‘Edit’, ‘generatepress’ ), ‘<span class=”edit-link”>’, ‘</span>’ ); ?>

    <?php else : ?>

    <li id=”comment-<?php comment_ID(); ?>” <?php comment_class( empty( $args[‘has_children’] ) ? ” : ‘parent’ ); ?>>
    <article id=”div-comment-<?php comment_ID(); ?>” class=”comment-body” itemscope itemtype=”https://schema.org/Comment”&gt;
    <footer class=”comment-meta”>
    <?php
    if ( 0 != $args[‘avatar_size’] ) {
    echo get_avatar( $comment, $args[‘avatar_size’] );
    }
    ?>

    <?php printf( ‘<cite itemprop=”name” class=”fn”>%s</cite>’, get_comment_author() ); ?>

    <!– .comment-author –>

    <!– .comment-metadata –>

    <!– .comment-author-info –>

    <?php if ( ‘0’ == $comment->comment_approved ) : ?>
    <p class=”comment-awaiting-moderation”><?php _e( ‘Your comment is awaiting moderation.’, ‘generatepress’ ); // WPCS: XSS OK. ?></p>
    <?php endif; ?>
    </footer><!– .comment-meta –>

    <?php comment_text(); ?>

    <!– .comment-content –>
    </article><!– .comment-body –>
    <?php
    endif;
    }
    }

    /*remove author link*/

    add_filter( ‘generate_post_author_output’,’tu_no_author_link’ );
    function tu_no_author_link() {
    printf( ‘ <span class=”byline”>%1$s</span>’,
    sprintf( ‘<span class=”author vcard” itemtype=”http://schema.org/Person&#8221; itemscope=”itemscope” itemprop=”author”>%1$s <span class=”fn n author-name” itemprop=”name”>%4$s</span></span>’,
    __( ‘by’,’generatepress’),
    esc_url( get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ),
    esc_attr( sprintf( __( ‘View all posts by %s’, ‘generatepress’ ), get_the_author() ) ),
    esc_html( get_the_author() )
    )
    );

    if ( is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
    echo ‘ | <span class=”comments-link”>’;
    comments_popup_link( __( ‘Leave a comment’, ‘generatepress’ ), __( ‘1 Comment’, ‘generatepress’ ), __( ‘% Comments’, ‘generatepress’ ) );
    echo ‘</span>’;
    }
    }

    /*showing tags*/
    <?php
    { $tags_list = get_the_tag_list( ”, _x( ‘, ‘, ‘Used between list items, there is a space after the comma.’, ‘generatepress’ ) );
    $tags_list = sprintf( ‘<span class=”tags-links”><span class=”screen-reader-text”>%1$s </span>%2$s</span>’,
    esc_html_x( ‘Tags’, ‘Used before tag names.’, ‘generatepress’ ),
    $tags_list
    );

    ?>

    <?php
    }
    ?>

    comment.php file:

    <?php
    /**
    * The template for displaying Comments.
    *
    * The area of the page that contains both current comments
    * and the comment form. The actual display of comments is
    * handled by a callback to generate_comment() which is
    * located in the inc/template-tags.php file.
    *
    * @package GeneratePress
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit; // Exit if accessed directly.
    }

    /*
    * If the current post is protected by a password and
    * the visitor has not yet entered the password we will
    * return early without loading the comments.
    */
    if ( post_password_required() ) {
    return;
    }

    /**
    * generate_before_comments hook.
    *
    * @since 0.1
    */
    do_action( ‘generate_before_comments’ );
    ?>

    <?php
    /**
    * generate_inside_comments hook.
    *
    * @since 1.3.47
    */
    do_action( ‘generate_inside_comments’ );

    if ( have_comments() ) : ?>
    <h3 class=”comments-title”>
    <?php
    $comments_number = get_comments_number();
    if ( 1 === $comments_number ) {
    printf(
    /* translators: %s: post title */
    esc_html_x( ‘One thought on “%s”’, ‘comments title’, ‘generatepress’ ),
    ‘<span>’ . get_the_title() . ‘</span>’
    );
    } else {
    printf( // WPCS: XSS OK.
    /* translators: 1: number of comments, 2: post title */
    esc_html( _nx(
    ‘%1$s comments/reviews’,
    ‘%1$s comments/reviews’,
    $comments_number,
    ‘comments title’,
    ‘generatepress’
    ) ),
    number_format_i18n( $comments_number ),
    ‘<span>’ . get_the_title() . ‘</span>’
    );
    }
    ?>
    </h3>

    <?php
    /**
    * generate_below_comments_title hook.
    *
    * @since 0.1
    */
    do_action( ‘generate_below_comments_title’ );

    if ( get_comment_pages_count() > 1 && get_option( ‘page_comments’ ) ) : ?>
    <nav id=”comment-nav-above” class=”comment-navigation” role=”navigation”>
    <h2 class=”screen-reader-text”><?php esc_html_e( ‘Comment navigation’, ‘generatepress’ ); ?></h2>

    </nav><!– #comment-nav-above –>
    <?php endif; ?>

      <?php
      /*
      * Loop through and list the comments. Tell wp_list_comments()
      * to use generate_comment() to format the comments.
      * If you want to override this in a child theme, then you can
      * define generate_comment() and that will be used instead.
      * See generate_comment() in inc/template-tags.php for more.
      */
      wp_list_comments( array(
      ‘callback’ => ‘generate_comment’,
      ) );
      ?>

    <!– .comment-list –>

    <?php if ( get_comment_pages_count() > 1 && get_option( ‘page_comments’ ) ) : ?>
    <nav id=”comment-nav-below” class=”comment-navigation” role=”navigation”>
    <h2 class=”screen-reader-text”><?php esc_html_e( ‘Comment navigation’, ‘generatepress’ ); ?></h2>

    </nav><!– #comment-nav-below –>
    <?php endif;

    endif;

    // If comments are closed and there are comments, let’s leave a little note, shall we?
    if ( ! comments_open() && ‘0’ != get_comments_number() && post_type_supports( get_post_type(), ‘comments’ ) ) : ?>
    <p class=”no-comments”><?php _e( ‘Comments are closed’, ‘generatepress’ ); // WPCS: XSS OK. ?></p>
    <?php endif;

    $defaults = array(
    ‘comment_field’ => ‘<p class=”comment-form-comment”><label for=”comment” class=”screen-reader-text”>’ . esc_html__( ‘Comment’, ‘generatepress’ ) . ‘</label><textarea id=”comment” name=”comment” cols=”45″ rows=”8″ aria-required=”true”></textarea></p>’,
    ‘comment_notes_before’ => ‘<p class=”comment-notes”><span id=”email-notes”>’ . __( ‘Your email address will not be published. We moderate all the comments and it takes 24 to 48 hours for the comments to appear. We thank you for your understanding. If you have made the recipe, then you can give a star rating with or without commenting.’ ) . ‘</span></p>’,
    ‘comment_notes_after’ => null,
    ‘id_form’ => ‘commentform’,
    ‘id_submit’ => ‘submit’,
    ‘title_reply’ => apply_filters( ‘generate_leave_comment’, __( ‘Leave a Comment or Review’, ‘generatepress’ ) ),
    ‘label_submit’ => apply_filters( ‘generate_post_comment’, __( ‘Post Comment/Review’, ‘generatepress’ ) ),
    );

    comment_form( $defaults );
    ?>

    <!– #comments –>

    #737556
    Tom
    Lead Developer
    Lead Developer

    So in your comment function, remove this:

    itemscope itemtype="https://schema.org/Comment"

    In your remove author link function, remove this:

    itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"

    #739451
    dassana

    thank you very much tom. i have removed these codes. i also removed a few more codes from the comment code. the comments schema is not there now. i have also removed schema generated by yoast plugin. any idea how to get rid of the schema generated by wp show posts plugin and what can be done with the hatom schema.

    #739468
    dassana

    also one more query. how i do remove the hcard schema which is generated by the comments code pasted below.

    <?php printf( ‘<cite itemprop=”name” class=”fn”>%s</cite>’, get_comment_author() ); ?>

    <!– .comment-author –>

    link to check – https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fwww.vegrecipesofindia.com%2Fkashmiri-dum-aloo%2F

    #740101
    Tom
    Lead Developer
    Lead Developer

    It’s not possible to remove those classes without overwriting the entire functions, currently.

    However, leaving them in will have no negative effect on your microdata.

    #743661
    dassana

    thanks tom for the info.

    #743925
    Tom
    Lead Developer
    Lead Developer

    No problem ๐Ÿ™‚

    #1025245
    dassana

    hi tom

    referring to this thread and one more thread for removing extra structured data, i have managed to get rid of hentry and other elements like wpsidebar, wpheader etc from the schema markup.

    if the following link is checked – https://search.google.com/structured-data/testing-tool/u/0/#url=https%3A%2F%2Fwww.vegrecipesofindia.com%2Fmatar-paneer%2F

    then there are still three markups appearing – hcard, creativework and person that i want to get rid of. i just want the recipe markup.

    1. hcard is contributed by generatepress theme. to remove hcard schema what code should i add.

    2. creativework by wp show posts pro plugin. since here i am using wp show posts pro to display popular recipes, what changes i need to do or what code should i add to remove the creative work schema.

    3. person schema is by another author box plugin. i am following up with the plugin team to remove this schema.

    regards
    dassana

    #1025790
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    1. I believe these are from the comments. It’s not possible to remove them right now, but I’m seeing what I can do about that in GP 2.4.

    2. This isn’t possible at the moment, unfortunately. WPSP needs to conditionally load the schema, which it isn’t doing (yet).

    #1026101
    dassana

    thanks tom. sure, i hope you manage to get this done in GP2.4
    i have removed wpsp code from all posts. so that solves it for now.

    #1055865
    dassana

    hi tom

    any update on removing the comment schema from GP2.4

    regards
    dassana

    #1056504
    Tom
    Lead Developer
    Lead Developer

    I wasn’t able to get a solid solution added to 2.4, unfortunately. This is still high on my priorities, I just want to make sure we do it right the first time ๐Ÿ™‚

Viewing 15 posts - 16 through 30 (of 32 total)
  • You must be logged in to reply to this topic.