WordPress Blog Posting Content Summary Primer Tutorial

WordPress Blog Posting Content Summary Primer Tutorial

WordPress Blog Posting Content Summary Primer Tutorial

We really like WordPress.org for the basis of this blog’s design (and recognize WordPress.com as a great idea for those not wanting to host their own Apache/PHP/MySql domain). And am sure you would not be surprised that I am not alone. Take a read of the excellent WordPress information by Websitebuilder.org and, reading closely, you’ll see how popular this blogging platform is, and mention of a number of famous people using it.

I’ve never had much trouble with WordPress, so, not all the time, but occasionally, I tweak it. For this, we suggest, as WordPress would, to use their Codex PHP (with MySql) coding advice, and on a personal level, though, you’ll see, reading this blog, that we also like the direct approach of, mainly, changing the header.php PHP code that sits in, for our case of a theme called TwentyTen (“twentyten” in lowercase) …


[documentRootOfWordPressWebsite]/wp-content/themes/twentyten/

Today’s tweak of header.php relates to a matter dear to our hearts. The desire to cater for mobile users with small screens, yet not be dumbing blog posting content down just for the sake of it. Today we channel just about our favourite reveal based idea you can read more about at HTML5 Details Summary Primer Tutorial to harness the goodies that came with HTML5 in the form of the …

Implementing this in header.php went like this …

  1. added into

    <body onload=" changeasfordownload(); if (cafd == cafd) { cafd=0; } else { cafd=true; } checkonl(); setTimeout(initpostedoncc, 3000); widgetcon(); precc(); courseCookies(); cookie_fonts(); is_mentioned_by(); calendar_pass(); prejustshow(); details_summary(0);">
  2. added a new emoji button up near the top …

    document.getElementById('site-title').innerHTML+='<a id="avs" style="text-decoration:none;" href=# onmouseover="getVisualSynopsis(event);" onmouseout="yehbut();" ontouchstart="getVisualSynopsis(event);" ontouchend="yehbut();" onclick=" uptop(); " title="... you can wait for the long hover functionality about Visual Synopsis (Slideshows)">&#127910;</a> <a style="cursor:pointer;text-decoration:none;" onclick="popselid();" title="Filter Content via Div ID">&#10135;</a> <a style="cursor:pointer;text-decoration:none;visibility:hidden;" title="Blog post contents reduced to summary" id="eds" onclick="pre_details_summary();">&#10134;</a>' + printscreen(0);
  3. then added these two new Javascript functions to suit those events defined above …


    function pre_details_summary() {
    var idos=0,dos=[];
    if (('' + document.getElementById("eds").title) == 'Blog post contents reduced to summary') {
    if (document.body.innerHTML.indexOf('<summary></summary>') == -1) {
    details_summary(1);
    } else {
    dos=document.getElementsByTagName('details');
    for (idos=0; idos<dos.length; idos++) {
    if (dos[idos].className == "gendetails") {
    dos[idos].removeAttribute('open');
    }
    }
    }
    document.getElementById("eds").innerHTML = "&#10133;";
    document.getElementById("eds").title = "Open up blog posting contents now";
    } else {
    dos=document.getElementsByTagName('details');
    for (idos=0; idos<dos.length; idos++) {
    if (dos[idos].className == "gendetails") {
    dos[idos].setAttribute('open', true);
    }
    }
    document.getElementById("eds").innerHTML = "&#10134;";
    document.getElementById("eds").title = "Blog post contents reduced to summary";
    }
    }

    function details_summary(mou) {
    var dbitssare=document.body.innerHTML.split('<div class="entry-content">');
    var dbitseare=document.body.innerHTML.split('<div class="entry-utility">');
    if (document.URL.indexOf('detailssummary=') != -1 || mou != 0) {
    if (dbitssare.length > 1 && dbitssare.length == dbitseare.length) {
    var dbih=document.body.innerHTML, idbih=1;
    for (var idb=0; idb<dbitssare.length; idb++) {
    if (('' + dbitssare[eval(1 + idb)]).indexOf('<p>') != -1) {
    if (('' + dbitssare[eval(1 + idb)]).split('<p>')[idbih].split('</p>')[0] == '') {
    if (('' + dbitssare[eval(1 + idb)]).split('<p>').length >= eval(1 + eval(idbih))) {
    idbih++;
    }
    }
    dbih=dbih.replace('<div class="entry-content">','<details class="gendetails" title="Click me to toggle open/close ... ' + ('' + dbitssare[eval(1 + idb)]).split('<p>')[idbih].split('</p>')[0].replace(/\'/g,'`').replace(/\"/g,'`').replace(/\>/g,'>').replace(/\</g,'<') + '"><summary></summary><div title="entry-content" class="entry-content">');
    } else {
    dbih=dbih.replace('<div class="entry-content">','<details class="gendetails" title="Click me to toggle open/close"><summary></summary><div title="entry-content" class="entry-content">');
    }
    dbih=dbih.replace('<div class="entry-utility">','</details><div title="entry-utility" class="entry-utility">');
    }
    document.body.innerHTML=dbih;
    }
    if (document.URL.indexOf('detailssummary=') != -1 && mou == 0) {
    document.getElementById("eds").innerHTML = "&#10133;";
    document.getElementById("eds").title = "Open up blog posting contents now";
    document.getElementById("eds").style.visibility='visible';
    }
    } else if (mou == 0 && dbitssare.length > 1 && dbitssare.length == dbitseare.length) {
    document.getElementById("eds").style.visibility='visible';
    }
    }

Of course, this is most of benefit when you are not already honing in on the one WordPress blog posting, but there’s more fun to come, we reckon!

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

2 Responses to WordPress Blog Posting Content Summary Primer Tutorial

  1. Katalogwww says:

    Very good site you have got here.

Leave a Reply to admin Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>