Support » Plugins and Hacks » How to put wp_days_ago inside class element?

How to put wp_days_ago inside class element?

  • Hi. I was trying to use this plugin to style posts differently according to their age. So I put the output of the template tag inside class element and tweak the CSS. For example, this works:

    <h3 class="<?php wp_days_ago(1); ?>">

    The problem is with post elements that use post_class. I want to add the wp_days_ago tag to all the other tags, not replace them.

    I have tried passing wp_days_ago to post_class as a parameter, but the result is something like ‘todayclass=”post”‘, instead of ‘class=”post today”‘.

    I’ve been trying with get_post_class, but I know little PHP and all I can get is either ‘Array’ or ‘Array(key > value)’, instead of ‘value value value’.

    I’d be grateful if anyone could do any suggestion.


Viewing 1 replies (of 1 total)
  • Plugin Author Vegard Skjefstad


    Hi David.

    I’m unfamiliar with how get_post_class works in your theme. Could you please provide an example from the theme?

    If the theme uses the post_class function, you might be able to do something like this (I’ve not tested it, though, so I have no idea if the code even compiles):

    <?php post_class(wp_days_ago(1)); ?>


Viewing 1 replies (of 1 total)
  • The topic ‘How to put wp_days_ago inside class element?’ is closed to new replies.