javascriptblogger

Display total number of posts with a set additional numbers


I'm using blogger platform and this script to display the total number of posts:

<script style="text/javascript">function mbhTotalCount(json) {document.write(parseInt(json.feed.openSearch$totalResults.$t,10));}</script><span class='count1'><script src="https://URL/feeds/posts/default?alt=json-in-script&callback=mbhTotalCount"></script></span>

While this is working and displays the number of total posts, I would like to add "32" to the total number displayed by this code for certain reasons. Is there any possibilities?


Solution

  • Yes this can be done just by modifying the mbhTotalCount function and breaking the functionality into smaller chunks of what you were doing earlier. Something like:

    <script>
    function mbhTotalCount(json) {
      var totalCount = parseInt(json.feed.openSearch$totalResults.$t, 10);
      var newCountVal = totalCount + 32;
      document.write(newCountVal);
    }
    </script>
    <span class='count1'>
      <script src="https://URL/feeds/posts/default?alt=json-in-script&callback=mbhTotalCount"></script>
    </span>