• Resolved Anonymous User 15382528

    (@anonymized-15382528)


    Hi Hesham,

    First of all, I would like to thank you for doing such a great job on your Schema Plugin. I have tested many other plugins and yours is the best 🙂

    I have 2 quick questions, I hope you can answer them:

    1) I noticed if I set a Woocommerce Product Page as an Article Type, then there will be 2 @type under the mainEntityOfPage section. Please see the screenshot below.

    https://screenpresso.com/=Ap6Rc

    Is this normal?

    2) I also noticed that the Description is truncated. Is there anyway to show the full description / content?

    https://screenpresso.com/=SmEgc

    Thanks very much for such a great plugin.

    Sam

    • This topic was modified 8 years, 8 months ago by Anonymous User 15382528.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Hesham Zebida

    (@hishaman)

    Hi Sam,

    Glad to hear that.

    1) Since WooCommerce pages are “Products” pages, you really don’t want to use the Schema plugin on them, especially that there is no support for “Product” markup in Schema plugin yet! (This will require some kind of integration and extra coding)

    The recommended option here would be disable Schema on WooCommerce products type.

    Another thing that may work, but I am not sure if it will cause errors in markup (this mostly because there is no integration between both plugins). Try overriding the Schema type output by setting it to “Product” and see if this solves the duplication issue ( I haven’t tested this):

    add_filter( 'schema_wp_types', 'schema_wp_new_add_schema_type_7623456' );
    /**
     * Add New type to Schema Types options
     *
     * @since 1.0
     */
    function schema_wp_new_add_schema_type_7623456( $options ) {
    	
    	// Change 'NewType' to the actual schema.org type you want to add
    	// Example: Event, Product, JobPosting, ...etc.
    	$options['NewType'] =  array ( 
    						'label' => __('NewType'),
    						'value'	=> 'NewType'
    						);	
    	return $options;
    }

    Here is a link to the code gist.

    2) Luckily, there is a filter for that, you can try this in your theme’s functions.php file, this will override the Schema describtion output and replace it with full content of the post:

    add_filter( 'schema_wp_filter_description', 'schema_wp_override_description_345675432567' );
    /*
    *	Override Schema description value, use full content instead 
    */
    function schema_wp_override_description_345675432567( $schema_output ) {
    	
    	global $post;
    	
    	// get post id
    	$post_id = $post->ID; 
    	// get post 
    	$content_post = get_post($post_id);
    	// get post content
    	$content = $content_post->post_content;
    	// remove shortcodes
    	$content = str_replace(']]>', ']]>', $content);
    	// remove html tags
    	$content = wp_strip_all_tags($content);
    	
    	// return new description
    	return $content;
    }

    Here is a link to the code gist.

    P.S. I’ve just added a new filter to override the description words count, but this will be part of the next plugin update.

    I hope this answers your questions.

    Thread Starter Anonymous User 15382528

    (@anonymized-15382528)

    Hi Hesham,

    Thanks very much for the reply and also the code samples. I am currently testing your codes.

    Regarding the code for adding new type, I have tried it as below, but it doesn’t seem to work. As you can see in this screenshot, Product Type still does not exist in the Dropdown options:

    https://screenpresso.com/=RzoOf

    https://screenpresso.com/=I2ygb

    ————————
    add_filter( ‘schema_wp_types’, ‘schema_wp_new_add_schema_type_7623456’ );
    /**
    * Add New type to Schema Types options
    *
    * @since 1.0
    */

    function schema_wp_new_add_schema_type_7623456( $options ) {

    // Change ‘NewType’ to the actual schema.org type you want to add
    // Example: Event, Product, JobPosting, …etc.
    $options[‘Product’] = array (
    ‘label’ => __(‘Product’),
    ‘value’ => ‘Product’
    );
    return $options;
    }
    ————————

    Did I make some mistake in editing the codes?

    By the way, Hesham, the reason that I prefer to use Schema plugin for Woocommerce items is that I would be able to use the Schema Review Plugin to add Review ratings to Woocommerce items. I think this can be extremely useful for SEO.

    I appreciate your help.

    Thanks again.

    Sam

    Thread Starter Anonymous User 15382528

    (@anonymized-15382528)

    Hi again Hesham,

    Update: Although I could not get your codes for function.php to work, but I tried editing the codes directly in the Schema Plugin’s meta.php file just to test your idea.

    However, I think it does not work. The 2 @type under mainentityofpage still exist, and there are some other errors. Please see below.

    https://screenpresso.com/=rWQQ

    Once again, my ultimate goal is to be able to use your Schema Review plugin with Woocommerce products. Would you consider making your Schema Review plugin to work with the json markup produced by native Woocommerce?

    Thanks again.

    Sam

    Plugin Author Hesham Zebida

    (@hishaman)

    Hi Sam,

    I am not sure why the code isn’t working for you, but I’ve just tested this exact code and it works:

    add_filter( 'schema_wp_types', 'schema_wp_new_add_schema_type_762345hjkjhhj6' );
    /**
    * Add New type to Schema Types options
    *
    * @since 1.0
    */
    function schema_wp_new_add_schema_type_762345hjkjhhj6( $options ) {
    	$options['Product'] = array (
    		'label' => __('Product'),
    		'value'	=> 'Product'
    	);
    	return $options;
    }

    You can see after adding the code, this is what I get:

    – For the duplicate type, I can’t really tell, I need to check the output live on your site, a link to your website will help.

    – For WooCommerce, I think if you are selling products on your site, you shouldn’t rate them yourself. I hope this makes sense.

    I am thinking seriously about adding an integration for WooCommerce (paid extension) but not sure when this will be ready.

    Plugin Author Hesham Zebida

    (@hishaman)

    I will mark this as solved.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Duplicate @type under mainEntityOfPage’ is closed to new replies.