This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

How to add comments to page with custom layout from the Layout Builder

  • Creator
    Topic
  • #12875
    vnp
    Participant

    I can force comments on pages, that works. Used the code

    function activate_page_comments( $setup ) {
        $setup['comments']['pages'] = true;
        return $setup;
    }
    add_filter( 'themeblvd_global_config', 'activate_page_comments' );

    But as soon as I choose a custom layout, the comment field disappears. Is there anyway to force the comments on custom layout pages as well?

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #12891
    Jason Bobich
    Keymaster

    Hello,

    A custom layout doesn’t have anything to do with the default page template and so there’s no way for this to work and display comments.

    You may be able to create an element for the layout builder that you could then add into your custom layout using the Layout Builder API.

    http://dev.themeblvd.com/tutorial/add-remove-builder-elements/

    For example, possibly something like this may do the trick:

    /**
     * Register comments element
     */
    themeblvd_add_builder_element( 'my_comments', 'Comments', 'none', array(), 'my_display_comments' );
    
    /**
     * Display comments element
     */
    function my_display_comments( $id, $options, $location ) {
        comments_template();
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.