Toolonomy Logo
Last Updated on: June 18, 2021

Oxygen Builder & WPDiscuz Integration [PHP Snippet]

If you want to integrate the wpDiscuz comment system plugin with Oxygen Builder then this PHP code snippet is going to help you make them work with one another just by adding a shortcode to the single post template of Oxygen Builder.

/**     
 * Add this code to the Oxygen Builder single post type content using a code block element.
 * @see https://github.com/soflyy/oxygen-bugs-and-features/issues/2214
*/
<?php comments_template(); ?>

OR

<?php

/**     
 * Display the comment template with the [ wpse_comments_template ] shortcode. Note: Remove the spaces between the shortcode and [] brackets.
 * shortcode on singular pages. 
 *
 * @see https://stackoverflow.com/a/28644134/2078474
 */
 add_shortcode( 'wpse_comments_template', function( $atts = array(), $content = '' )
 {
    if( is_singular() && post_type_supports( get_post_type(), 'comments' ) )
    {
        ob_start();
        comments_template();
        add_filter( 'comments_open',       'wpse_comments_open'   );
        add_filter( 'get_comments_number', 'wpse_comments_number' );
        return ob_get_clean();
    }
    return '';
}, 10, 2 );

function wpse_comments_open( $open )
{
    remove_filter( current_filter(), __FUNCTION__ );
    return false;
}

function wpse_comments_number( $open )
{
    remove_filter( current_filter(), __FUNCTION__ );
    return 0;
}

Explore our Facebook Community

Consider joining our Toolonomy Facebook Community if you want to involve in the group discussion with like-minded people about Business Development Tools.
Join Now
Made with ❤ for Digital Entrepreneurs
Copyright © 2018 - 2022 SyncWin | All Rights Reserved.
Top crossmenu