Editing Theme(s)
-
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>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','<img src="','" alt="<?php the_title(); ?>" class="post-image" />',''); ?> - <h2 class='latest'>");
the_category(' ');
echo ("</h2> - <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 ('
<?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')) : ?><?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 ("\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("');
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?
- The topic ‘Editing Theme(s)’ is closed to new replies.