• I’m trying to use the great timeago plugin from http://timeago.yarp.com/ in my theme.

    I’ve added this to my functions.php file

    function wpb_adding_scripts() {
    wp_register_script('jquery_timeago', plugins_url('/js/jquery.timeago.js', __FILE__), array('jquery'),'1.1', true);
    wp_enqueue_script('jquery_timeago');
    }
    
    add_action( 'jquery_timeago', 'wpb_adding_scripts' );

    then at the top of the template page I’m adding

    <script type="text/javascript">
    jQuery(document).ready(function() {
      jQuery("abbr.timeago").timeago();
    });
    </script>

    and where I’m testing it in the body of the page I have

    <abbr class="timeago" title="2007-07-17T09:24:17Z">July 17, 2007</abbr>

    which is copied from the example on the website.

  • The topic ‘load/use jQuery time ago in theme’ is closed to new replies.