Forums

Getting the last post meta in category list view (2 posts)

  1. andres
    Member
    Posted 1 year ago #

    Hi i was wondering if someone can help me accomplish this D:

    What im trying to do is getting a custom field on my category listing so far i got this :

    <?php
    $args=array(
      'orderby' => 'name',
      'order' => 'ASC'
      );
    $categories=get_categories($args);
      foreach($categories as $category) { 
    
        echo '<p>Anime: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all Episodes of %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
        echo '<p> Description:'. $category->description . '</p>';
        echo '<p>We have: '. $category->count . '</p>';  }

    Witch only comes from the category.php and i need to grab a custom field from the last post in each category i guess it has to be something with echo get_post_meta anyways i hope i get someone to help ^^

    Thanks in advance.

  2. richarduk
    Member
    Posted 1 year ago #

    I would probably start here:

    http://codex.wordpress.org/Template_Tags/get_posts

    For one category, order=ASC and get one post should get the last post; then extract the custom field?

    For multiple categories I'm not so sure

Topic Closed

This topic has been closed to new replies.

About this Topic