We help IT Professionals succeed at work.

retreive thumbnail from child pages and style current page thumbnail differently

mattleedc
mattleedc asked
on
Hi Experts,

On child pages, I would like to have thumbnails of all other child pages with the same parent.  I have the following code (and using Advanced Custom fields plugin):

<ul>

<?php query_posts(array('showposts' => 20, 'post_parent' => 7, 'post_type' => 'page')); while (have_posts()): the_post(); ?>

<li class"<if this is the current page give class current>">
<h2><?php the_field('field_name'); ?></h2>
</li>

<?php endwhile ?>

</ul>

I can get it to create a list, but not add a class to the current page item.  

I hope the above makes some sense!
Comment
Watch Question

Don't talk to me.
Commented:
Something like this?

<?php
$poststoshow = 5;
if(is_single()) { $currentpost = get_the_ID(); }

$posts = get_posts('numberposts='.$poststoshow); ?>
<ul>
<?php
foreach ($posts as $post) { 

	setup_postdata($post);
	static $count1 = 0; 

	if ($count1 == "5") {
		break;
	}
	else { ?>
		<li<?php if($currentpost == $post->ID) { echo ' class="current"'; } ?>><?php the_title();?></li>
		<?php
		//the_content();
		$count1++;
	}
} ?>
</ul>
<?php
unset($posts);
$posts = get_posts('numberposts='.$poststoshow.'&offset='.$count1);
?>
<ul>
<?php
foreach ($posts as $post) {

	setup_postdata($post);
	static $count2 = 0;
	if ($count2 == "5") {
		break;
	}
	else { ?>
		<li<?php if($currentpost == $post->ID) { echo ' class="current"'; } ?>><?php the_title();?></li>
		<?php
		//the_content();
		$count2++;
	}
}
?>
</ul>

Open in new window


Source: http://wordpress.org/support/topic/how-to-highlight-current-post-title-in-multiply-lists
Jason C. LevineDon't talk to me.

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.