WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Hacking c2c_get_recent_posts - need some php help (4 posts)

  1. 3stripe
    Member
    Posted 8 years ago #

    I'm trying to add a new variable to Coffee2Code's extension to show customizable post listings...

    I want 'the_category' to simply display the category of each post. But because my PHP is really bad I can only get it to display on the page using 'echo', when I really want to assign it to the variable 'new'.

    Can anyone help me out?

    case '%the_category%':
    foreach((get_the_category()) as $cat) {
    echo $cat->cat_name;
    $new = $cat;
    }
    break;

  2. 3stripe
    Member
    Posted 8 years ago #

    Think I got it, although not sure if this is the right way to do this!

    case '%the_category%':
    foreach((get_the_category()) as $cat) {
    $new = $cat->cat_name;
    }
    break;

  3. iand
    Member
    Posted 8 years ago #

    Just for reference, where do you use that code?

  4. 3stripe
    Member
    Posted 8 years ago #

    I've posted the code at http://wordpress.org/support/topic/51607 as this thread should be closed/deleted really.

Topic Closed

This topic has been closed to new replies.

About this Topic