• Resolved makta112

    (@makta112)


    Hello

    I’m trying to replace the “published on”-dates on my site with “relative time”, eg. 2 minutes ago, 4 hours ago, 2 days ago, etc.

    I’ve uploaded this plugin: http://ww.wp.xz.cn/extend/plugins/wp-relative-date/

    But I can’t make it work. The plugin discription say that I need to insert this get_relative_date this to call it. But I don’t know where?

    My site http://geimaku.com

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael

    (@alchymyth)

    as you are working with a child theme of Twenty Eleven, the post date is displayed using the function ‘twentyeleven_posted_on()’;

    to integrate the plugin function into the date output, add this function to functions.php of the child theme:

    http://pastebin.com/cBKLp4aF

    (unless you have edited the date function already – then paste that code into a pastebin.com and post the link to it here)

    main edits explained –
    general structure:
    (function_exists('get_relative_date')?'this':'that')
    which translates into english as:
    if the plugin function exists, do ‘this’, otherwise do ‘that’.

    the change here adapts the wording conditional on the use of the plugin:

    printf( __( '<span class="sep">Posted '.(function_exists('get_relative_date')?'':'on').' </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a>'.(function_exists('get_relative_date')?' ago':'').'<span class="by-au.....

    and here conditionally to add the plugin function get_relative_date() in place of get_the_date():

    esc_html( (function_exists('get_relative_date')?get_relative_date():get_the_date()) ),
    Thread Starter makta112

    (@makta112)

    Hi,

    Thanks!

    I did what you said… But I think I did it wrong somehow.

    So I copied all the codes from the Twenty Eleven parent theme’s functions.php and placed it in the child’s functions.php

    I then removed these lines from the child’s functions.php and replaced it with your codes.

    Where did I go wrong?

    Michael

    (@alchymyth)

    So I copied all the codes from the Twenty Eleven parent theme’s functions.php and placed it in the child’s functions.php

    – never copy the full functions.php from the parent theme into a child theme.

    if your child theme did not have a functions.php, just make an empty new functions.php file, and add

    <?php

    at the very start in the first line;

    then add any new code below that into the functions.php in the child theme.

    Thread Starter makta112

    (@makta112)

    Now it works, thanks alchymyth!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Relative time?’ is closed to new replies.