I need HELP re-arranging the content of my posts
-
Hi there,
I’m trying to get my posts to show up with the first image of the post at the top, then the title, then the post text, then the rest of the images.
|img |
|title|
|text |
|img |
|img |
|img |
|…..|I’m somewhat succeful in breaking down the posts into parts and rearranging them.
<?php get_header();?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="post_single" id="post-<?php the_ID(); ?>"> <?php $beforeEachImage = "<div>"; $afterEachImage = "</div>"; preg_match_all("/(<img [^>]*>)/",get_the_content(),$matches,PREG_PATTERN_ORDER); for( $i=0; isset($matches[1]) && $i < count($matches[1]); $i++ ) { echo $beforeEachImage . $matches[1][$i] . $afterEachImage; } ?> <div id="post"> <h2 class="small"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php edit_post_link('- Edit Post'); ?></h2> <br><div class="postmetadata-top"><small><?php the_date('F d, Y'); ?> </small></div> </div> <div class="content"><?php ob_start(); the_content('Read the full post',true); $postOutput = preg_replace('/<img[^>]+./','', ob_get_contents()); ob_end_clean(); echo $postOutput; ?> </div> </div> <?php endwhile; ?> <?php endif; ?> <?php get_footer();?>
Using the above code I get this:
|img |
|img |
|img |
|img |
|…..|
|title|
|text |I tried using
<?php echo catch_first_image() ?>
but that just gives me a link to the image and doesn’t display the image.
Also how would I adress the remaining images to be shown at the bottom of the post?Best regards,
thf
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘I need HELP re-arranging the content of my posts’ is closed to new replies.