• Resolved louisgcom

    (@louisgcom)


    Hello

    First, thank you much for your work!
    I would like to add structured data on multiple pages, like on front page and contact page. Unfortunately, I’m unable to hook a condition to do that.

    My request is really simple, can you please add a filter on your $show_in_page variable in google_business_reviews_rating::structured_data() function?
    With a filter on this variable, any developer would be able to change a bit your plugin behavior and check if the current page is a specific content-type, ID, … and then print or not schema markup in header.

    Best regards,

    • This topic was modified 10 months, 1 week ago by louisgcom.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Design Extreme

    (@designextreme)

    @louisgcom This functionality already exists.

    You can display the Structured Data on any single page in your website. In the wp_options table, change the option with option_name: google_business_reviews_rating_structured_data to the Post ID of the page.

    According to the Schema documentation, they recommend only including this once per website. So, find a good location and set this as the page. I’ve covered this in more detail in an old forum post.

    If you just want the Structured Data, there is a Shortcode for this, which can also run within do_shortcode():

    [reviews_rating structured_data]
    Thread Starter louisgcom

    (@louisgcom)

    Thank you I missed this option for your shortcode.

    I did it this way because it returns structured data in a <pre> element:

    add_filter(
    	'the_content',
    	function ( $content ) {
    		if ( is_page( 'contact' ) ) {
    			return $content .
    				preg_replace(
    					'/<(\/?)pre[^>]*>/',
    					'<$1script>',
    					do_shortcode(
    						'[reviews_rating structured_data]'
    					)
    				);
    		}
    		return $content;
    	},
    	1
    );
    
    • This reply was modified 10 months, 1 week ago by louisgcom.
    • This reply was modified 10 months, 1 week ago by louisgcom.
    • This reply was modified 10 months, 1 week ago by louisgcom.
    Plugin Author Design Extreme

    (@designextreme)

    @louisgcom I’ll add a new Shortcode without the <pre>.

    [reviews_rating structured_data outer_tag=false]

    You can switch it out the <pre> with <script> if you wish:

    [reviews_rating structured_data html_tags="script"]

    This will be in the next release. I’ll tag you here when it’s live.

    • This reply was modified 10 months, 1 week ago by Design Extreme. Reason: Added script example
    Plugin Author Design Extreme

    (@designextreme)

    @louisgcom Please download version 4.27 which supports the new parameters as mentioned here.

    I’ve also added a singular version of the parameter: html_tags ( html_tag ) that offers a fall-back.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add a filter’ is closed to new replies.