PHP Gurus, foreach question, WP related
I need to grab post information ( title, excerpt and post count ) and echo that information outside of the loop.
So far, I can do this with the post count and title. I've bolded the relevant code.
<?php $titles = array(); $tmp = $wp_query; $wp_query = new WP_Query('posts_per_page=' .$my_admin_option['theme_index_featured_postcount']. ''); if(have_posts()) : while(have_posts()) : the_post(); $titles[] = get_the_title($post->ID); <img src="<?php echo $image[0]; ?>" class="attachment-post-thumbnail-600x396" title="#caption<?php echo count($titles)-1; ?>" alt="<?php the_title_attribute(); ?>" /> <?php endwhile; endif; $wp_query = $tmp; ?> </div> <?php foreach( $titles as $key => $title ) { ?> <div id="caption<?php echo $key; ?>"> <h2><?php echo $title; ?></h2> </div> <?php } ?> |
Now, how do I expand the array to include additional post information? I'm trying to include the post excerpt.
I've been messing around with
$titles["title"] = get_the_title
$titles["excerpt"] = get_the_excerpt
but I can't figure it out.
Every Day Is Fun! :)
The 2nd Amendment, 1789 - The Original Homeland Security.
Gun control means never having to say, "I missed you."
The 2nd Amendment, 1789 - The Original Homeland Security.
Gun control means never having to say, "I missed you."