Last Updated on: June 18, 2021

Oxygen Builder & WPDiscuz Integration [PHP Snippet]

0 Shares

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://sync.win/KkPa
 */
 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;
}
SyncWin Logo
SyncWin is a dedicated place to explore the Content, Discussions, & Useful Details around topics like Business, Technology, and Lifestyle to help you learn and grow in your life.
About Us
Made with ❤ for WinSyncers
Copyright © 2018 - 2025 by SyncWin | All Rights Reserved.
crossmenuarrow-right
0 Shares
Copy link