[Support request] Add Comments and User Review Stars to a page built with Sections

Home Forums Support [Support request] Add Comments and User Review Stars to a page built with Sections

Home Forums Support Add Comments and User Review Stars to a page built with Sections

  • This topic has 5 replies, 2 voices, and was last updated 4 years ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #823201
    Francesco

    Hello there,
    I would love to add Comments and Review Stars to a page built with sections. (looks like that works only without sections active)
    Comments at the end of the page.
    User Review Stars on top of the contents.

    The page (via Rank Math seo plugin) is marked on schema markup as “article”, I’ve already switched to “review” but nothing has changed.

    How can I add these two things in the cleanest and effective way?
    Thanks for your support.

    [the page I’m referring is the home page]

    GP Premium 1.7.8
    #823914
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Sections by default were never built to include comments or any sort of automatically placed content. The reason is that those items don’t know which Section to add themselves to.

    There is a potential solution here: https://generatepress.com/forums/topic/comments-using-sections/#post-325331

    How did you switch the schema to reviews? Are you wanting to only change it on this one page?

    #824928
    Francesco

    Hi Tom,
    thanks for your explanation, I have switched to a page without section, now comments load as expected!

    1.
    Regards schema data “review stars” I have tried 2 different plugins: one is “Rank Math” seo plugin the other is “Schema & Structured Data for WP” BUT both show me only editors rating.
    Replying at your question: yes at this stage I would love to add only to this specific page (but if there is a viable solution is ok also to the entire site)
    I’m looking for a solution where users can rate the article[page] and assign stars based on their preference. My goal is to display reviews stars inside Google serp snippet. (and if I’m not wrong the solution is by schema micro-data).

    2.
    I’m also looking to display, in the beginning of the page, the standard “date” and “author name” info. Is there a way to display also on pages instead of articles (where are displayed by default).

    Thanks for your support.
    Francesco

    #825096
    Tom
    Lead Developer
    Lead Developer

    1. You could try this function:

    add_filter( 'generate_article_itemtype', function( $type ) {
        return 'Review';
    } );

    However, changing the itemtype like this might review you to make some other adjustments to the content/HTML.

    2. Give this a shot:

    add_filter( 'generate_entry_meta_post_types', function( $types ) {
        $types[] = 'page';
    
        return $types;
    } );

    Let me know 🙂

    #825252
    Francesco

    I have added both via snippet plugin …but seems not working…
    maybe I need to add in other way…is not clear in my mind…
    thanks

    #825764
    Tom
    Lead Developer
    Lead Developer

    Hmm, try this instead:

    add_action( 'after_setup_theme', function() {
        add_filter( 'generate_article_itemtype', function( $type ) {
            return 'Review';
        } );
    
        add_filter( 'generate_entry_meta_post_types', function( $types ) {
            $types[] = 'page';
    
            return $types;
        } );
    } );
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.