removing links from blog feed title if contains < 16 words
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 11 Jan 2016 17:17:59 +0000 (12:17 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 11 Jan 2016 17:17:59 +0000 (12:17 -0500)
js/app.js
js/custom/pageSetup.js
parts/blog-feed-home.php

index e2b73f6..4a508ee 100644 (file)
--- 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 $("<h2 />", {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;
index 29fbb3d..f5c96b3 100644 (file)
@@ -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 $("<h2 />", {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;
index 4429f72..5efda11 100644 (file)
@@ -2,6 +2,7 @@
 <div id="home-feed-posts">
 <?php
 $lastposts = get_posts( $args );
+    $count = 0;
 foreach($lastposts as $post) : setup_postdata($post); ?>
     <div class="home-feed-post">
         <div class="row">
@@ -15,10 +16,11 @@ foreach($lastposts as $post) : setup_postdata($post); ?>
                 <?php } ?>
                 <h2 class="title-posts" href="<?php the_permalink(); ?>"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                 <span class="meta date">Posted on <?php the_time('F jS, Y') ?></span>
-                <div><?php echo the_advanced_excerpt('length=225&length_type=characters&no_custom=1&ellipsis=%26hellip;&exclude_tags=a,img,p,strong,h1,h2,h3,hr,div'); ?></div>
+                <div class="excerpt<?php echo $count ?>"><?php echo the_advanced_excerpt('length=225&length_type=characters&no_custom=1&ellipsis=%26hellip;&exclude_tags=a,img,p,strong,h1,h2,h3,hr,div'); ?></div>
             </div>
         </div>
     </div>
     <hr>
+        <?php $count++; ?>
 <?php endforeach; ?>
 </div>
\ No newline at end of file