WordPress.org

Ready to get started?Download WordPress

Forums

wp-days-ago
How to put wp_days_ago inside class element? (2 posts)

  1. David M.
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/plugins/wp-days-ago/

  2. Vegard Skjefstad
    Member
    Plugin Author

    Posted 1 year ago #

    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)); ?>

    reference

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.