I'm totally lost :)
I have a loop which outputs:
- POST ITLE
- POST CONTENT
- POST META
And...
In every post I have an image at the beginning of the CONTENT area.
How to get this image ABOVE the title and do something like:
- FIRST IMAGE FROM CONTENT
- POST TITLE
- THE REST OF THE CONTENT
- POST META
?
I have no clue how to get things out of the loop.
I'd love to see some snippet here, I guess I should maybe use wp query, but never did this before.
Thanks a lot.
MY CURRENT LOOP CODE ("stolen" from TwentyTen default Wordpress theme as I'm still learning):
/* I WANT TO PUT CONTENT IMAGE HERE AND TAKE IT FROM 6TH LINE OF THE CODE BELOW:*/
<article <?php post_class(); ?>>
<header>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
</header>
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>') ); ?> /* I WANT TO TAKE FIRST IMAGE FROM HERE BADLY :) :) :) */
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<?php endif; ?>
<div class="entry-utility">
<?php if ( count( get_the_category() ) ) : ?>
<span class="cat-links">
<?php printf( __( '%2$s'), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
<time><?php the_time('m F Y') ?></time>
</span>
<?php endif; ?>
<?php
$tags_list = get_the_tag_list( '', ', ' );
if ( $tags_list ):
?>
<span class="tag-links">
开发者_C百科 <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
</span>
<?php endif; ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment'), __( '1 Comment'), __( '% Comments') ); ?></span>
<?php edit_post_link( __( 'Edit'), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-utility -->
</article><!-- #post-## -->
I know this code isn't perfect, but at this moment I'm just learning and playing :)
Tnks! :)
The answer was "featured image" function... :)
精彩评论