Remove Disqus comment box from main Tumblr page, but keep comment boxes for each post's page?

三世轮回 提交于 2019-12-25 02:57:44

问题


I haven't found a solution to my problem on StackOverflow or Google, so I figured I'd ask.

I added Disqus to my custom theme Tumblr blog, but I want to change where the Disqus comment box/system appears. In particular, I do not want it to show up on the main Tumblr page, but I'd like it to appear on the page for each post. So, if you go to my Tumblr's main page you will see the Disqus system at the bottom - I want to remove it from there. But, I would like the Disqus system to appear on each post's page: see how it appears on the bottom of "Second test post"'s unique page.

Any ideas on how to accomplish this would be appreciated. Everything I've tried just removes Disqus from every page. Thank you!

The body of my Tumblr's HTML is below:

<body>
    <div id="wrapper">
        <div id="headerleft">
            <h1><a href="{BlogURL}" title="read my thoughts">Blog</a></h1>
            <ul id="menu">
                <li><a href="http://michelemasiello.com" title="home">home</a></li>
                <li>&nbsp&nbsp|&nbsp&nbsp</li>
                <li><a href="http://michelemasiello.com/projects.html" title="check out my work">projects</a></li>
                <li>&nbsp&nbsp|&nbsp&nbsp</li>
                <li><a href="mailto:msm@michelemasiello.com" title="email me">say hello</a></li>
            </ul>
        </div>
        <div id="headerright">
            <p>"Everything has been thought of before, but the problem is to think of it again."<br>&#8212;&nbspJohann Wolfgang von Goethe</p>
        </div>
        <div id="recentposts">
            <ul id="postlist"></ul>
        </div>

        {block:Posts}

            {block:Text}
            <div class="post">
                {block:Title}
                    <h2><a href="{Permalink}">{Title}</a></h2>
                {/block:Title}
                {Body}
                <br>
                <ul class="like-reblog">
                  <li>{LikeButton color="black"}</li>
                  <li>{ReblogButton color="black"}</li>
                  <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                  <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                  <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                  <script type="text/javascript">
                    var disqus_shortname = '{text:Disqus Shortname}';
                    (function () {
                        var s = document.createElement('script'); s.async = true;
                        s.type = 'text/javascript';
                        s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                    }());
                </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {/block:Text}

            {block:Photo} 
            <div class="post">  
                <img src="{PhotoURL-500}">
                {block:Caption}{Caption}{/block:Caption}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                    <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Photo}

            {block:Quote}
            <div class="post">
                {Quote}
                {block:Source}<br>&mdash;{Source}{/block:Source}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Quote}

            {block:Link}
            <div class="post">
                <a href="{URL}" {Target}>{Name}</a>
                {block:Description}{Description}{/block:Description}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Link}

            {block:Chat}
            <div class="post">
                {block:Title}{Title}{/block:Title}
                <table>
                    {block:Lines}
                    <tr>
                        <th>{block:Label}{Label}{/block:Label}</th>
                        <td>{Line}</td>
                    </tr>
                    {/block:Lines}
                </table>
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Chat}

            {block:Audio}
            <div class="post">
                {AudioPlayer}
                {block:Caption}{Caption}{/block:Caption}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Audio}

            {block:Video}
            <div class="post">
                {Video-500}
                {block:Caption}{Caption}{/block:Caption}
                <ul class="like-reblog">
                    <li>{LikeButton}</li>
                    <li>{ReblogButton}</li>
                    <li>{block:NoteCount}<a href="{Permalink}#notes">{NoteCountWithLabel}</a>{/block:NoteCount}</li>
                    <li>{block:Date}<a href="{Permalink}">{TimeAgo}</a>{/block:Date}</li>
                    <li>{block:IndexPage}<a class="dsq-comment-count" href="{Permalink}#disqus_thread">Comments</a>
                      <script type="text/javascript">
                        var disqus_shortname = '{text:Disqus Shortname}';
                        (function () {
                            var s = document.createElement('script'); s.async = true;
                            s.type = 'text/javascript';
                            s.src = '//' + disqus_shortname + '.disqus.com/count.js';
                            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
                        }());
                    </script>{/block:IndexPage}</li>
                </ul>
            </div>
            {block:PostNotes}{PostNotes}{/block:PostNotes}
            {/block:Video}

        {/block:Posts}


        {block:IfDisqusShortname}
        <div id="disqus_thread"></div>
        <script type="text/javascript">
            /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
            var disqus_shortname = '{text:Disqus Shortname}'; // Required - Enter shortname in Tumblr Theme Options
            var disqus_url = '{Permalink}'; 

            /* * * DON'T EDIT BELOW THIS LINE * * */
            (function() {
                var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
                (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
            })();
        </script>
        <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
        <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
        {/block:IfDisqusShortname}


        {block:Pagination}
        <div class="pagenav">
            {block:PreviousPage}<a href="{PreviousPage}">Previous</a>{/block:PreviousPage}
            {block:NextPage}<a href="{NextPage}">Next</a>{/block:NextPage}
        </div>
        {/block:Pagination}



    </div>
</body>

回答1:


Add {block:PermalinkPage} before {block:IfDisqusShortname} and add {/block:PermalinkPage} after {/block:IfDisqusShortname} like this:

{block:PermalinkPage}
    {block:IfDisqusShortname}
        //Disqus' code
    {/block:IfDisqusShortname}
{/block:PermalinkPage}


来源:https://stackoverflow.com/questions/28489987/remove-disqus-comment-box-from-main-tumblr-page-but-keep-comment-boxes-for-each

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!