How to Fix Related Post Bug in Median UI V1.7

How to Add Bug Related Post Median ui 1.7

 

Some time ago, RojakDesign updated one of its themes called Median UI from the previous version 1.6 to version 1.7.

In the current version, 1.7, I found a number of natural bugs because all the code in the theme was all rewritten, as for what I can't share how to fix because the code is encrypted.



but what I will discuss in this post is that related post bugs sometimes appear sometimes not, whereas in the previous version this never happened.


actually I see from the javascript that is used it is not much different from the previous one, it is possible that the script was damaged when in minifi.


for those of you who experience something similar, you can use the script that I have modified below.


Are you struggling with a bug in Median UI 1.7 that's affecting your related posts? Don't worry, we've got you covered! In this article, we'll show you step-by-step how to fix the related post bug in Median UI 1.7. Whether you're a beginner or an experienced user, our simple and easy-to-understand instructions will help you resolve this issue and get your related posts back on track. So, let's dive in and get your website's related posts functioning smoothly once again!


Identifying the Issue:

Upon analyzing the updated theme, I noticed that the code had been completely rewritten in version 1.7. As a result, several unforeseen bugs surfaced, specifically concerning the inconsistent appearance of related posts. This behavior was not observed in the previous version, indicating a potential issue introduced during the rewriting process.


Examining the JavaScript:

Comparing the JavaScript used in the current version (1.7) with the previous one, I found that there weren't significant differences. It is likely that the script was damaged during the minification process, which could explain the sporadic occurrence of related post bugs.



Step 1: First of all Login to your Blogger Dashboard.

Step 2: On Blogger Dashboard, click Theme.

Step 3: Click the arrow down  icon next to the 'Customize' button.

Step 4: Choose Edit HTML, you will be redirected to the editing page.

Step 5: Next search the below Script code and replace with above script the JavaScript code.

please go to blogger > theme > edit html find the code like below


<script>/*<![CDATA[*/ /*! Related Post Widget for Blogger by Taufik Nurrohman <https://github.com/taufik-nurrohman> */
!function(e,t,a){if("object"==typeof labelArray&&labelArray.length)for(var l=t.createElement("em"),i=0,s=labelArray.length;i<s;++i)l.innerHTML=labelArray[i],labelArray[i]=l.textContent;var n=(new Date).getTime(),r={widgetTitle:"<h3 class='title'>Related Posts</h3>",widgetStyle:1,homePage:"//www.jagodesain.com",numPosts:6,summaryLength:180,titleLength:"auto",thumbnailSize:300,noImage:"data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",containerId:"relatedPost",newTabLink:!1,moreText:"Read more",callBack:function(){}};if("object"==typeof relatedPostConfig)for(var i in relatedPostConfig)r[i]=relatedPostConfig[i];r.homePage=r.homePage.replace(/\/?\?m=\d+(\&|$)|\/+$/,"");var o=function(e){var l=t.createElement("script");l.src=e,a.appendChild(l)},m=function(e){var t,a,l=e.length;if(0===l)return!1;for(;--l;)t=Math.floor(Math.random()*(l+1)),a=e[l],e[l]=e[t],e[t]=a;return e},h="object"==typeof labelArray&&labelArray.length?"/-/"+encodeURIComponent(m(labelArray)[0]):"";e["do_related_post_"+n]=function(e){var a,l,i,s,n,ct,dt,Y,M,D,MM,o=t.getElementById(r.containerId),h=m(e.feed.entry),c=r.widgetStyle,d=r.widgetTitle+'<div class="itemR type-'+c+' flex wrap scrlH" role="feed">',u=r.newTabLink?' target="_blank"':"",mm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];if(o){for(var p=h.length,A=0;A<r.numPosts&&A!==p;A++){l=h[A].title.$t,i="auto"!==r.titleLength&&r.titleLength<l.length?l.substring(0,r.titleLength)+"&hellip;":l,s="media$thumbnail"in h[A]&&!1!==r.thumbnailSize?h[A].media$thumbnail.url.replace(/\/s\d+(\-c)?\//,"/s"+r.thumbnailSize+"/"):r.noImage,n="summary"in h[A]&&r.summaryLength>0?h[A].summary.$t.replace(/<br *\/?>/gi," ").replace(/<.*?>/g,"").replace(/[<>]/g,"").substring(0,r.summaryLength)+"&hellip;":"",ct=h[A].category[0].term,dt=h[A].published.$t.substring(0, 29),Y=dt.substring(0,4),M=dt.substring(5,7),D=dt.substring(8,10),MM=mm[parseInt(M-1)];for(var f=0,y=h[A].link.length;f<y;f++)if("alternate"==h[A].link[f].rel){a=h[A].link[f].href;break}d+=2==c||3==c?'<article class="flex column"><div class="pI shrink"><a aria-label="Thumbnail" class="image" href="'+a+'"'+u+'><div class="mi lazy" data-style="background-image:url('+s+')"></div></a></div><div class="pC grow flex column"><div class="pH info flex fontM"><time class="time ellips opacity shrink" data-text="'+MM+' '+D+'" datetime="'+dt+'" title="Published on: '+MM+' '+D+', '+Y+'"></time><div class="label ellips cInherit"><a aria-label="Tag" data-text="'+ct+'" href="'+r.homePage+'/search/label/'+ct+'" rel="tag"></a></div></div><div class="pT cInherit"><h4 class="name"><a class="clamp" href="'+a+'"'+u+">"+i+"</a></h4></div></div></article>":4==c?'<article class="flex column shrink"><div class="pI shrink"><a aria-label="Thumbnail" class="image" href="'+a+'"'+u+'><div class="mi lazy" data-style="background-image:url('+s+')"></div></a></div><div class="pC grow flex column"><div class="pH info flex fontM"><time class="time ellips opacity shrink" data-text="'+MM+' '+D+'" datetime="'+dt+'" title="Published on: '+MM+' '+D+', '+Y+'"></time><div class="label ellips cInherit"><a aria-label="Tag" data-text="'+ct+'" href="'+r.homePage+'/search/label/'+ct+'" rel="tag"></a></div></div><div class="pT cInherit"><h4 class="name"><a class="clamp" href="'+a+'"'+u+'>'+i+'</a></h4></div><div class="pS fontM"><div class="snippet clamp opacity">'+n+"</div></div></div></article>":'<article class="flex"><div class="pI shrink"><a aria-label="Thumbnail" class="image" href="'+a+'"'+u+'><div class="mi lazy" data-style="background-image:url('+s+')"></div></a></div><div class="pC grow"><div class="pH info flex fontM"><time class="time ellips opacity shrink" data-text="'+MM+' '+D+'" datetime="'+dt+'" title="Published on: '+MM+' '+D+', '+Y+'"></time><div class="label ellips cInherit"><a aria-label="Tag" data-text="'+ct+'" href="'+r.homePage+'/search/label/'+ct+'" rel="tag"></a></div></div><div class="pT cInherit"><h4 class="name"><a class="clamp" href="'+a+'"'+u+">"+i+"</a></h4></div></div></article>"}o.innerHTML=d+="</div>",r.callBack(e)}},e["do_related_post_start_"+n]=function(e){var t,a,l=e.feed.openSearch$totalResults.$t-r.numPosts,i=(t=1,a=l>0?l:1,Math.floor(Math.random()*(a-t+1))+t);o(r.homePage+"/feeds/posts/summary"+h+"?alt=json-in-script&orderby=updated&start-index="+i+"&max-results="+r.numPosts+"&callback=do_related_post_"+n)},o(r.homePage+"/feeds/posts/summary?alt=json-in-script&orderby=updated&max-results=0&callback=do_related_post_start_"+n)}(window,document,document.getElementsByTagName("head")[0]); /*]]>*/</script>

If you find it, replace it with the code below

<script>/*<![CDATA[*/ /*! Related Post Widget for Blogger by Taufik Nurrohman <https://github.com/taufik-nurrohman> */
var randomI,callRelated;(function(a,e,l){var t={widgetTitle:"<h3 class='title'>Related Posts</h3>",widgetStyle:1,homePage:"https://www.wendycode.com",numPosts:7,summaryLength:320,titleLength:"auto",thumbnailSize:200,noImage:"data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",containerId:"relatedPost",newTabLink:false,moreText:"Read more",callBack:function(){}};for(var i in relatedPostConfig){t[i]=relatedPostConfig[i]=="undefined"?t[i]:relatedPostConfig[i]}var s=function(a){var t=e.createElement("script");t.async="async";t.rel="preload";t.src=a;l.appendChild(t)},r=function(a,e){return Math.floor(Math.random()*(e-a+1))+a},n=function(a){var e=a.length,l,t;if(e===0){return false}while(--e){l=Math.floor(Math.random()*(e+1));t=a[e];a[e]=a[l];a[l]=t}return a},c=typeof labelArray=="object"&&labelArray.length>0?"/-/"+n(labelArray)[0]:"",d=function(a){var e=a.feed.openSearch$totalResults.$t-t.numPosts,l=r(1,e>0?e:1);s(t.homePage.replace(/\/$/,"")+"/feeds/posts/summary"+c+"?alt=json-in-script&orderby=updated&start-index="+l+"&max-results="+t.numPosts+"&callback=callRelated")},o=function(a){var l=document.getElementById(t.containerId),i=n(a.feed.entry),s=t.widgetStyle,r=t.widgetTitle+'<div class="itemR type-'+s+' flex wrap scrlH" role="feed">',c=t.newTabLink?' target="_blank"':"",d=t.moreText,o,m,h,u,g;if(!l){return}for(var p=0;p<t.numPosts;p++){if(p==i.length){break}m=i[p].title.$t;h=t.titleLength!=="auto"&&t.titleLength<m.length?m.substring(0,t.titleLength)+"&hellip;":m;u="media$thumbnail"in i[p]&&t.thumbnailSize!==false?i[p].media$thumbnail.url.replace(/.*?:\/\//g,"//").replace(/\/s[0-9]+(\-c)?/,"/s"+t.thumbnailSize).replace(/\=s[0-9]+(\-c)?/,"=s"+t.thumbnailSize).replace("1.bp.blogspot.com","2.bp.blogspot.com"):t.noImage;month=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];date=i[p].published.$t.substring(0,10);Y=date.substring(0,4);e=date.substring(5,7);D=date.substring(8,10);M=month[parseInt(e-1)];g="summary"in i[p]&&t.summaryLength>0?i[p].summary.$t.replace(/<br ?\/?>/g," ").replace(/<.*?>/g,"").replace(/[<>]/g,"").substring(0,t.summaryLength)+"&hellip;":"";for(var b=0,v=i[p].link.length;b<v;b++){o=i[p].link[b].rel=="alternate"?i[p].link[b].href:"#"}var f=i[0].category[0].term;var y=i[0].published.$t.substring(0,29);if(s==2){r+='<article class="flex column"><div class="pI shrink"><a aria-label="Thumbnail" class="image" aria-label="'+h+'" href="'+o+'" title="'+m+'"><div class="mi lazy" data-style="background-image:url('+u+')"></div></a></div><div class="pC grow flex column"><div class="pH info flex fontM"><time class="time ellips opacity shrink" data-text="'+M+" "+D+'" datetime="'+y+'" title="Published on: '+M+" "+D+", "+Y+'"></time><div class="label ellips cInherit"><a aria-label="Tag" data-text="'+f+'" href="'+t.homePage+"/search/label/"+f+'" rel="tag"></a></div></div><div class="pT cInherit"><h4 class="name"><a class="clamp" aria-label="'+h+'" href="'+o+'" title="'+m+'">'+h+"</a></h4></div></div></article>"}else{if(s==3){r+='<article class="flex"><div class="pI shrink"><a aria-label="Thumbnail" class="image" aria-label="'+h+'" href="'+o+'" title="'+m+'"><div class="mi lazy" data-style="background-image:url('+u+')"></div></a></div><div class="pC grow"><div class="pT cInherit"><h4 class="name"><a class="clamp" aria-label="'+h+'" href="'+o+'" title="'+m+'">'+h+"</a></h4></div></div></article>"}else{if(s==4){r+='<article class="flex column shrink"><div class="pI shrink"><a aria-label="Thumbnail" class="image" aria-label="'+h+'" href="'+o+'" title="'+m+'"><div class="mi lazy" data-style="background-image:url('+u+')"></div></a></div><div class="pC grow flex column"><div class="pH info flex fontM"><time class="time ellips opacity shrink" data-text="'+M+" "+D+'" datetime="'+y+'" title="Published on: '+M+" "+D+", "+Y+'"></time><div class="label ellips cInherit"><a aria-label="Tag" data-text="'+f+'" href="'+t.homePage+"/search/label/"+f+'" rel="tag"></a></div></div><div class="pT cInherit"><h4 class="name"><a class="clamp" aria-label="'+h+'" href="'+o+'" title="'+m+'">'+h+'</a></h4></div><div class="pS fontM"><div class="snippet clamp opacity">'+g+"</div></div></div></article>"}else{r+='<article class="flex column"><div class="pI shrink"><a aria-label="Thumbnail" class="image" aria-label="'+h+'" href="'+o+'" title="'+m+'"><div class="mi lazy" data-style="background-image:url('+u+')"></div></a></div><div class="pC grow flex column"><div class="pH info flex fontM"><time class="time ellips opacity shrink" data-text="'+M+" "+D+'" datetime="'+y+'" title="Published on: '+M+" "+D+", "+Y+'"></time><div class="label ellips cInherit"><a aria-label="Tag" data-text="'+f+'" href="'+t.homePage+"/search/label/"+f+'" rel="tag"></a></div></div><div class="pT cInherit"><h4 class="name"><a class="clamp" aria-label="'+h+'" href="'+o+'" title="'+m+'">'+h+"</a></h4></div></div></article>"}}}}l.innerHTML=r+="</div>";t.callBack()};randomI=d;callRelated=o;s(t.homePage.replace(/\/$/,"")+"/feeds/posts/summary"+c+"?alt=json-in-script&orderby=updated&max-results=0&callback=randomI")})(window,document,document.getElementsByTagName("head")[0]);
 /*]]>*/</script>

Conclusion:

In the transition from version 1.6 to 1.7 of Jago Desain's Median UI theme, some unforeseen bugs, specifically related to the display of related posts, have emerged. Although the exact code fix cannot be shared due to encryption, I have presented a potential solution through a modified script. Implementing this solution requires caution and thorough testing. If you encounter any difficulties or persistent issues, don't hesitate to seek help from the appropriate channels.

About the author

Daud
Hey! I'm Daud, Currently Working in IT Company BD. I always like to learn something new and teach others.

Post a Comment

To avoid SPAM, all comments will be moderated before being displayed.
Don't share any personal or sensitive information.