Skip to main content

Content Management
Content Management

All about Creating Content and Content Types

89 followers
83 questions
10 posts

Do you have questions about Content Management?

Log in to ask questions about Content Management publicly or anonymously.

Shivam Sharma
Full Stack Web Developer at IndiaMART

I made a script for the same after spending 2 hours for the same. Add this script in the box present at the below path.

Admin Settings -> Theme -> Advanced Settings -> Code added to the end of <body> tag

<!-- Start of Poll Sorting Script -->
<script type="text/javascript">
function sortPoll(){
  var poll_wrapper = document.querySelectorAll(".question-poll-wrapper");
  poll_wrapper.forEach(function(ele){
    if(!ele.getAttribute("data-poll-sorted")){
      var item_arr = ele.querySelectorAll(".question-poll-item");
      ele.innerHTML="";
      Array.from(item_arr).sort(function(a,b){
        if(a.querySelector(".percent-value") && b.querySelector(".percent-value")){
          var cnt_a = parseInt(a.querySelector(".percent-value").innerText);
          var cnt_b = parseInt(b.querySelector(".percent-value").innerText);
          return cnt_b-cnt_a;
        }
        else{
          return 0;
        }
      }).forEach(function(item){
        ele.appendChild(item);
      });
      ele.setAttribute("data-poll-sorted",1);
    }
  });
}
var sortPollInterval = setInterval(sortPoll,500);
</script>
<!-- End of Poll Sorting Script -->

I request Tribe team to get this added default to all community or provide a feature for the same. It'll be very helpful. Please share if there's any flaw in the script, though working fine in my community.