WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Disqus AND `comments_template();` running together? (2 posts)

  1. simon.ker
    Member
    Posted 1 year ago #

    Ok - so i am having all sorts of problems migrating a blogger blog to a self hosted wordpress with a custom theme that i have made.

    The main remaining problem is that the new blog needs to have the disqus comment system and I have tried to import the old comments to the disqus account that i have set up but it always fails (possibly because there are 39000+ comments). so I have decided to hopefully save some time and keep the old comments in their default wordpress form and use disqus only for new comments. Is there a way to change.

    <?php comments_template(); ?>

    So that it can check the date and if it is later than date x use disqus else use the old comments template?

  2. simon.ker
    Member
    Posted 1 year ago #

    Worked out a way to do this based on the category that the blog post appears in

    Basically all posts in the "blogger posts" category will use the wordpress comment system and all other posts will use disqus. this code pasted into functions.php will stop discuss activating on post in "blogger posts"

    add_filter( 'the_content' , 'disable_disqus_comments' );
    function disable_disqus_comments( $content ) {
            $catid =get_category_id('blogger posts');
            if( in_category('blogger posts')) {
                    remove_filter('comments_template', 'dsq_comments_template');
    
            }
            return $content;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic