From 0ad086a34dcfd739592dfb57e081af2bfcae0781 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Mon, 11 Jan 2016 12:17:59 -0500 Subject: [PATCH] removing links from blog feed title if contains < 16 words --- js/app.js | 16 ++++++++++++++++ js/custom/pageSetup.js | 16 ++++++++++++++++ parts/blog-feed-home.php | 4 +++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index e2b73f6..4a508ee 100644 --- a/js/app.js +++ b/js/app.js @@ -103,6 +103,22 @@ $(document).ready(function () { $(this).parent("li").addClass("current"); } }); + + // remove link from posts with less than 16 words + for (var i = 0; i < $('div[class*="excerpt"]').length; i++){ + var words = $(".excerpt" + i).text().split(' '); + if(words.length < 16){ + + alert($(".excerpt" + i).parent().find("a").attr("href")); + $(".excerpt" + i).parent().find("a").replaceWith(function(){ + return $("

", {html: $(this).html()}); + }); + } + } + +// alert(words.length); +// var words = $('div[class*="excerpt"])').text().split(' '); +// alert(words.length); /* get number of elements in DOM console.log($("*").length); var pageBytes = $('html').html().length; var kbytes = pageBytes / 1024; diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index 29fbb3d..f5c96b3 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -94,6 +94,22 @@ $(document).ready(function () { $(this).parent("li").addClass("current"); } }); + + // remove link from posts with less than 16 words + for (var i = 0; i < $('div[class*="excerpt"]').length; i++){ + var words = $(".excerpt" + i).text().split(' '); + if(words.length < 16){ + + alert($(".excerpt" + i).parent().find("a").attr("href")); + $(".excerpt" + i).parent().find("a").replaceWith(function(){ + return $("

", {html: $(this).html()}); + }); + } + } + +// alert(words.length); +// var words = $('div[class*="excerpt"])').text().split(' '); +// alert(words.length); /* get number of elements in DOM console.log($("*").length); var pageBytes = $('html').html().length; var kbytes = pageBytes / 1024; diff --git a/parts/blog-feed-home.php b/parts/blog-feed-home.php index 4429f72..5efda11 100644 --- a/parts/blog-feed-home.php +++ b/parts/blog-feed-home.php @@ -2,6 +2,7 @@
@@ -15,10 +16,11 @@ foreach($lastposts as $post) : setup_postdata($post); ?>

Posted on -
+

+ \ No newline at end of file -- 2.17.1