ph91.de
  • Home
  • About me
  • Categories
    • Software Development
    • New Zealand
    • Music
    • Tech & IT
    • Sports
    • Dublin
    • Junk
  • Contact
  • Disclaimer
ph91.de
ph91.de
  • Home
  • About me
  • Categories
    • Software Development
    • New Zealand
    • Music
    • Tech & IT
    • Sports
    • Dublin
    • Junk
  • Contact
  • Disclaimer
  • Software Development

Highlight newest entries in wpDataTables

  • 13. April 2016
  • Philipp
Speed-kini.de rankings with latest additions highlighted.

While developing for speed-kini.de I came across the issue that people didn’t recognize change in the ranking on first sight. Thus I wanted to highlight entries which have been added in the recent days. WpDataTables has a feature called “conditional formatting” which allows you to apply css classes to cells under certain conditions.

wpDataTables Conditional Formatting
wpDataTables Conditional Formatting

Unfortunately these conditions are static. For my purposes I need a dynamic condition which considers the current date. After a bit of research I found a way how to highlight with a dynamic condition.

  1. Go to the wpDataTables settings. Scroll to the place where you can fill in custom JavaScript and CSS.
  2. Edit the JavaScript:
    jQuery(document).ready(function( $ ) {
        $('.entry-date').each(function() {
          var dateString = $(this).text();
          var parts = dateString.split(".");
          var date = new Date(2000 + parseInt(parts[2]), parseInt(parts[1])-1, parts[0]);
          var now = new Date();
          var diff = parseInt((now - date) / (24 * 3600 * 1000));
          if (diff < 3) {
            $(this).parent().addClass("new-entry");
          }
        });
    });
    
  3. Edit the CSS:
  4. .new-entry{
        color: green !important;
        font-style:italic;
    }
    
  5. Update the column which contains your date parameter:
    Add specified class to your column.
    Add specified class to your column.

    The JavaScript isn’t the prettiest but it works so far. The result looks like this:

    Speed-kini.de rankings with latest additions highlighted.

Related Topics
  • column
  • css
  • highlight
  • javascript
  • row
  • speed-kini
  • wordpress
  • wpDataTables
Philipp

Previous Article
  • Software Development

Generating Rankings with counter variables in MySQL

  • 31. March 2016
  • Philipp
View Post
Next Article
  • Software Development

GPS Analytics up & running

  • 16. April 2016
  • Philipp
View Post
86 comments

Comments navigation

Older comments
  1. PokerPhantom says:
    30. October 2025 at 11:25

    https://t.me/Best_promocode_rus/1612

  2. LuckyBandit says:
    30. October 2025 at 21:46

    https://t.me/s/Beefcasino_rus/57

  3. MichaelSpers says:
    1. November 2025 at 20:32

    https://t.me/s/ud_1XsLOtS

  4. MichaelSpers says:
    2. November 2025 at 09:31

    https://t.me/s/UD_LegzO

  5. Caseydrusy says:
    2. November 2025 at 12:07

    https://t.me/s/tf_1win

  6. BluffMaster says:
    2. November 2025 at 12:45

    https://t.me/s/official_1win_aviator/92

  7. StevenGok says:
    2. November 2025 at 14:30

    https://t.me/s/tf_1win

  8. StevenGok says:
    2. November 2025 at 16:27

    https://t.me/s/kfo_1win

  9. AlbertDioke says:
    2. November 2025 at 21:02

    https://t.me/s/ud_MOstBeT

  10. AlbertDioke says:
    3. November 2025 at 05:22

    https://t.me/s/Ud_gAMa

  11. AlbertDioke says:
    3. November 2025 at 06:31

    https://t.me/s/ud_jeT

  12. LuckyBandit says:
    3. November 2025 at 20:25

    https://t.me/official_1win_aviator/78

  13. JamesBlade says:
    4. November 2025 at 09:40

    https://t.me/s/ke_Casino_X

  14. JamesBlade says:
    4. November 2025 at 10:47

    https://t.me/s/ke_Jet

  15. JamesBlade says:
    4. November 2025 at 12:57

    https://t.me/s/ke_GGBet

  16. JamesBlade says:
    4. November 2025 at 15:13

    https://t.me/s/ke_kent

  17. JamesBlade says:
    4. November 2025 at 16:18

    https://t.me/s/ke_MrBit

  18. JamesBlade says:
    4. November 2025 at 19:39

    https://t.me/s/kef_Lex

  19. JamesBlade says:
    4. November 2025 at 21:36

    https://t.me/s/ke_Pin_Up

  20. JamesBlade says:
    5. November 2025 at 01:31

    https://t.me/s/ke_mellstroy

  21. JamesBlade says:
    5. November 2025 at 06:02

    https://t.me/s/ke_Flagman

  22. JamesBlade says:
    5. November 2025 at 07:53

    https://t.me/s/ke_Irwin

  23. JamesBlade says:
    5. November 2025 at 10:51

    https://t.me/s/ke_Pinco

  24. JamesBlade says:
    5. November 2025 at 15:27

    https://t.me/s/ke_Kometa

  25. JamesBlade says:
    5. November 2025 at 16:26

    https://t.me/s/kef_Rox

  26. JamesBlade says:
    5. November 2025 at 18:39

    https://t.me/s/ke_Pokerdom

  27. JamesBlade says:
    5. November 2025 at 20:48

    https://t.me/s/ke_Gama

  28. DealerShadow says:
    5. November 2025 at 23:08

    https://t.me/official_1win_aviator/201

  29. JamesBlade says:
    6. November 2025 at 01:44

    https://t.me/s/ke_Drip

  30. JamesBlade says:
    6. November 2025 at 04:21

    https://t.me/s/ke_Vulkan

  31. JamesBlade says:
    6. November 2025 at 09:02

    https://t.me/s/ke_1Go

  32. JamesBlade says:
    6. November 2025 at 10:01

    https://t.me/s/ke_JoyCasino

  33. JamesBlade says:
    6. November 2025 at 15:09

    https://t.me/s/ke_DragonMoney

  34. JamesBlade says:
    6. November 2025 at 18:16

    https://t.me/s/ke_Monro

  35. Georgeunofe says:
    7. November 2025 at 14:42

    https://t.me/s/top_kazino_z

  36. Georgeunofe says:
    7. November 2025 at 16:44

    https://t.me/s/topcasino_v_rossii

Comments navigation

Older comments

Leave a Reply

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

Dev profiles
  • BitBucket
  • Github
  • Stackoverflow
Side Projects
  • NMF
  • Speed-kini.de
  • Sudoku Solver
  • Windwarner
Archive
ph91.de
Blog by Philipp Schreitmüller

Input your search keywords and press Enter.