Title: Editing Theme(s)
Last modified: August 19, 2016

---

# Editing Theme(s)

 *  [sophistikat](https://wordpress.org/support/users/sophistikat/)
 * (@sophistikat)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/editing-themes-5/)
 * Hello Everyone,
    I downloaded an theme who has this piece of code ` <ul class
   ="latest"><!-- ActionScript --> <?php $feature_post = get_posts( 'category=4&
   numberposts=1' ); ?> <?php foreach( $feature_post as $post ) : setup_postdata(
   $post ); ?>
    - <h2 class="latest"><?php the_category(' '); ?></h2>
    - <?php endforeach; ?>
       <?php $feature_post = get_posts( 'category=4&numberposts
      =1' ); ?> <?php foreach( $feature_post as $post ) : setup_postdata( $post );?
      > <?php if (function_exists('c2c_get_custom')) : ?>
    - " title="<?php the_title(); ?>">
       <?php echo c2c_get_custom('post-image','
      <img src="','" alt="<?php the_title(); ?>" class="post-image" />',''); ?>
    - <?php endif; ?>
       <li class="list-time"><?php the_time('d'); ?>.<?php the_time('
      M'); ?> <li class="list-title">" rel="bookmark"><?php the_title(); ?> <li 
      class="latest-excerpt"><?php the_excerpt(); ?> <?php endforeach; ?>
    - It works nicely but to show 10 list, you have to write the UL 10 times. So
      I am trying to put the code inside a function to streamline my code.
    - `
       function dev_showCat ($catNumber, $numberPosts) { print("<ul class='latest'
      >\n");
    -  #Show Category
       $feature_post = get_posts("category=6&numberposts=1"); foreach(
      $feature_post as $post ) : setup_postdata( $post ); echo ("
    - <h2 class='latest'>");
       the_category(' '); echo ("</h2>
    - \n");
       endforeach;
    -  #Show Post
       $feature_post = get_posts("category=6&numberposts=1"); foreach(
      $feature_post as $post ) : setup_postdata( $post ); #Show Image if (function_exists('
      c2c_get_custom')) : print("
    - <a href='");
       the_permalink(); print("' title='"); the_title(); print("'>");
      echo c2c_get_custom('post-image','<img src="','" alt="<?php the_title(); ?
      >" class="post-image" />',''); print ('
    - ');
       endif;
    -  #Show Timestamp
       print("<li class='list-time'>"); the_time('d'); print(".");
      the_time('M'); print("");
    -  #Show Post Title
       print("<li class='list-title'><a href='"); the_permalink();
      print("' rel='bookmark'>"); the_title(); print("");
    -  #Show Excerpt
       print("<li class='latest-excerpt'>"); the_excerpt(); print("");
      endforeach;
    -  print ("\n");
       }
    - This KINDA works. It returns an UL the way the original code does but the 
      only thing it doesn’t listen too is the get_posts() query. What am I missing?
      Is there a scope issue?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [iridiax](https://wordpress.org/support/users/iridiax/)
 * (@iridiax)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/editing-themes-5/#post-897485)
 * [http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)
 *  Thread Starter [sophistikat](https://wordpress.org/support/users/sophistikat/)
 * (@sophistikat)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/editing-themes-5/#post-897733)
 * putting the code in a function didn’t work so i just put the code in a seperate
   file and loaded the file multiple times as an include.
 *     ```
       #Number Posts Per Category
       $category_posts=1; 
   
       $category_num=3; #ActionScript
       include (TEMPLATEPATH . '/ul_latest.php');
       ```
   
 * I do have another question about get_posts
 *     ```
       $feature_post = get_posts( "category=$category_num&numberposts=1" );
       foreach( $feature_post as $post ) : setup_postdata( $post );
   
       <li><h2 class="latest"> the_category(' '); </h2></li>
       ```
   
 * how can i say, only return the Parent? i’ve looked at the codex for get_posts
   and all the parameters point to defining how many children to get?!
 * Here’s what I have.
    Parent: ActionScript Child: MovieClip Child of MovieClip:
   onEnterFrame
 * So if my post would be in ActionScript > MovieClip > onEnterFrame
 * i am using get_posts, setup_postdata and the_category to retrieve my latest post,
   which work but the_category returns ActionScript MovieClip onEnterFrame. I want
   it to return just the parent ActionScript

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Editing Theme(s)’ is closed to new replies.

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [sophistikat](https://wordpress.org/support/users/sophistikat/)
 * Last activity: [17 years, 6 months ago](https://wordpress.org/support/topic/editing-themes-5/#post-897733)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
