Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • #555171

    By default comments are allowed for Posts and disabled for Pages.
    If you want to use Disqus on static pages, you’ll need to install the Disqus plugin, enable comments, and then make the following manual changes inside Appearance > Editor
    It works great on my popular travel website http://www.bigboytravel.com/europe/austria/vienna/freewalkingtour/

    In comments.php replace all code with:

    <?php if (comments_open()) : ?>
    <div id="disqus_thread"></div>
    <script>
        /**
         *  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
         *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
         */
        /*
        var disqus_config = function () {
            this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
            this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
        };
        */
        (function() {  // DON'T EDIT BELOW THIS LINE
            var d = document, s = d.createElement('script');
            
            s.src = '//EXAMPLE.disqus.com/embed.js';
            
            s.setAttribute('data-timestamp', +new Date());
            (d.head || d.body).appendChild(s);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <?php endif; // comments_open ?>

    In loop-page.php add:
    comments_template( '/includes/comments.php');
    right above:
    echo '<footer class="entry-footer">';

    Hope that helps,
    Jon

    #555227

    Hey Jon!

    thanks a lot for sharing your solution with us!!

    Cheers!
    Andy

    #630692

    Thanks:)

    #631160

    Hi,

    Much appreciated @millertimesites :-)

    Best regards,
    Rikard

    #890336

    I have noticed that this solution for Disqus is still working with the pages that I am using the Visual Composer editor for, but is no longer working for the pages which use the AVIA editor. I just started to convert all my my pages from to AVIA so I can ditch Visual Composer and noticed the issue.
    Is there another change I should make to my Comments.php or PageLoop.php?

    #890776

    Hi millertimesites,

    There is an error in JavaScript of the Disqus. How are you adding it?

    Best regards,
    Victoria

    #890864

    Victoria,

    The Null error on the Disqus Embed only seems to be showing up in the pages with the AVIA editor and works great on the other 230 pages of the site`

    I have still been using the method listed above by replacing the contents of comments.php with the code above.
    One tweak to the code above is to replace the s.src = ‘//EXAMPLE.disqus.com/embed.js’; with my own identifier supplied by Disqus (see private comments)

    Then in PageLoop.php I added
    comments_template( ‘/includes/comments.php’);
    right above:
    echo ‘<footer class=”entry-footer”>’;

    #890893

    Hi millertimesites,

    Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?

    Best regards,
    Victoria

    #890912

    here you go, my PHP edits are on the parent theme as I have been weary of overriding the parent PageLoop.php in the Child Theme

    #891034

    Victoria,

    I had opened a ticket with Disqus also and they said that the code and set up was correct and that they believed it was likely an issue with the Enfold theme. To test I first disabled all plugins except Disqus however the comments still wouldn’t show up on pages using the AVIA editor. Once I switched from Enfold to the default WordPress theme of Twenty Seventeen however the Disqus comments showed up on every page with no problems.

    Since using the Visual Composer plugin instead of AVIA lets the Disqus show up and disabling the theme also lets Disqus show up I am inclined to agree with them at it looks like a them/editor issue. I hope your team is able to find a solution as Disqus is the #1 comments plugin on WordPress. This is the last hurdle I have left for moving my popular travel blog over to Enfold as finding a solution for Disqus will allow me to finally ditch Visual Composer for AVIA.

    Thanks again for looking into this!
    Jon

    #891223

    Hi millertimesites,

    I see you trying to include the /includes/comments.php and the comments.php is not in the includes folder. So that does not look correct.

    Best regards,
    Victoria

    #891328

    I switched the code in pageloop.php to have the correct file path but it didn’t make a difference
    comments_template( ‘/comments.php’);

    Disqus comments are still working fine on pages using Visual Composer with the change
    ex: https://www.bigboytravel.com/europe/austria/hallstatt/

    But are still not working on pages using Enfold’s Avia Editor
    ex: https://www.bigboytravel.com/italy/siena/

    #891388

    Hi millertimesites,

    It should be comments_template( ‘../comments.php’); since the comments.php is not in the same folder.

    Best regards,
    Victoria

    #892410

    Think I figured it out, maybe?
    I copied the contents of my custom comments.php shown above to my child theme
    In that code I replaced the unique identifier and s.src = ‘//EXAMPLE.disqus.com/embed.js’; with the handle related to my Disqus account just like I did before.

    Then I added the code below to the parent theme’s template-builder.php file on line 59 (above the sidebar and footer call code) instead of putting it into the loop-page.php file

    // Disqus
    comments_template( '/wp-content/themes/enfold-child/comments.php');

    This seems to be working correctly on this page using Enfold’s AVIA Advanced Layout Builder for the editor
    https://www.bigboytravel.com/europe/topmedievalcities/

    Did I do it right?

    #892427

    Hi,

    Yes, if it’s loading and working properly then that means you did it right :)

    Best regards,
    Nikko

    #918737

    Update:
    With the Newest theme update

    // Disqus
    comments_template( '/wp-content/themes/enfold-child/comments.php');

    Must now go right above this inside template-builder.php (roughly line 102)
    //only close divs if the user didnt add fullwidth slider elements at the end. also skip sidebar if the last element is a slider

    to make Disqus show up on static Pages when using the Enfold AVIA Editor.

    If you are using Visual Composer instead of AVIA then you will follow the placement listed above inside of loop-page.php
    loop-page.php can be found under the “includes” toggle while Template-builder.php is one of the main ones in the editor

    If you have a mixture of pages with both editors for some reason you will have to do both methods

    Jon

    #919524

    Hi,


    @millertimesites
    : Thanks for the info. I’m sure it will help a lot of users. :)

    Best regards,
    Ismael

    #937358

    Ismael and team,
    In an effort to make this thread on Disqus even better I was wondering if you can help with On-Demand Loading.
    Want to do this because Disqus sends 150-180 requests every time it is loaded on a page and really lags the full page render.
    Even tried adding Disqus files to the PreLoad inside WP Engine but it still sends a million requests.

    I have seen a number of sites using Disqus that have a “Load Comments” button at the bottom and it does call Disqus until it is clicked.
    One solution is on GitHub but I can’t seem to get it to work
    https://gist.github.com/nternetinspired/7482445

    Currently, as mentioned above, I have this as my comments.php with my Disqus handle/shortname replacing EXAMPLE for the src

    <?php if (comments_open()) : ?>
    <div id="disqus_thread"></div>
    <script>
        /**
         *  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
         *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
         */
        /*
        var disqus_config = function () {
            this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
            this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
        };
        */
        (function() {  // DON'T EDIT BELOW THIS LINE
            var d = document, s = d.createElement('script');
            
            s.src = '//EXAMPLE.disqus.com/embed.js';
            
            s.setAttribute('data-timestamp', +new Date());
            (d.head || d.body).appendChild(s);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <?php endif; // comments_open ?>

    With that code, this is my call for placement
    comments_template( '/includes/comments.php');

    GitHub recommends this instead

    $(document).ready(function() {
        $('.show-comments').on('click', function(){
              var disqus_shortname = 'YOUR-DISQUS-USERNAME'; // Replace this value with *your* username.
    
              // ajax request to load the disqus javascript
              $.ajax({
                      type: "GET",
                      url: "http://" + disqus_shortname + ".disqus.com/embed.js",
                      dataType: "script",
                      cache: true
              });
              // hide the button once comments load
              $(this).fadeOut();
        });
    });

    It then mentions to use this but the button never opens

    <!-- An element a visitor can click if they <3 comments! -->
    <button class="show-comments">Load Disqus comments</button>
    
    <!-- The empty element required for Disqus to loads comments into -->  
    <div id="disqus_thread"></div>
    #937947

    Hi,

    That would actually require to add some div wrappers to elements at Disquss plugin and make it load based on those.
    It is better to consider hire a freelancer to help you with that and maybe post the plugin back to the community.

    Thank you

    Best regards,
    Basilis

Viewing 19 posts - 1 through 19 (of 19 total)
  • You must be logged in to reply to this topic.