Viewing 7 replies - 1 through 7 (of 7 total)
  • I once managed something similiar (I think). get_recent_posts can’t do the category but I used the following:
    <?php c2c_get_recent_posts(1,'<div class="post"><h2>%post_date%</h2> <h2 class="title">%post_URL%</h2><div class="meta">Filed by: %post_author%</div><div class="content">%post_content%&nbsp;<div class="feedback">category | <a href=%comments_url%> %comments_fancy%</a></div></div></div>','','date','DESC','0','F jS, Y',''); ?>

    You should be able to copy and paste to get all the code.

    Hope that helps.

    Thread Starter 3stripe

    (@3stripe)

    Hey thanks Ian…. i’ve just been tring to hack the plugin and by adding this in the “Perform percent substitutions” loop I’ve almost got the category to show up now!

    case '%the_category%':
    $new = $new = the_category();
    break;

    So now I just include %the_category% when I call the function… but the category seems to be doing funny things to the layout as it’s a link as well. Back to drawing board!

    I’ve just edited my code a little. If you do get the category to work can you post your solution for others to use?

    Thread Starter 3stripe

    (@3stripe)

    Sure will…

    If you have a look at http://www.tonguengroove.co.uk/index.php you’ll see the category is working, but not quite in the right place…

    I think it might be due to the link in the_category() so I’m going to try calling the unlinked version instead and then relink it

    Thread Starter 3stripe

    (@3stripe)

    Can’t work out how to feed in the category name…

    I need to write something like:

    $new = category_nicename;

    But I can only do this using the get_the_category function? (http://codex.wordpress.org/Template_Tags/get_the_category)

    Thread Starter 3stripe

    (@3stripe)

    Got it working 🙂

    Will post full solution when I’ve spoken to the plugin author!

    Thread Starter 3stripe

    (@3stripe)

    Line 265-ish of customizable-post-listings.php, add:

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

    Line 309-ish of the same file, in the list of percentage tags, add:

    “%post_category%”, // The category of the post

    Now when calling c2c_get_recent_posts you can include the category using %post_category% 😀

    Please note I’ve change the name to %post_category% instead of %the_category% to make it consistent with the rest of the plugin. At the moment this only adds the category name, not a link to the category. Still working on that!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Showing metadata with get_recent_posts ?’ is closed to new replies.