• I’d like to create a list of subpages that shows the page’s thumbnail and its title. I modified the code from this post:

    http://wordpress.org/support/topic/349266?replies=2

    And now I have something that works in my sidebar, in a PHP widget:

    <ul class="side-nav">
    
    <?php
    $my_query = new WP_Query('post_type=page&post_parent=3&order=ASC');
     while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    <?php $image_thumb = get_post_meta($post->ID, 'image-thumb', true); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?>
    
    <?php the_title(); ?></a></li>
    
    <?php endwhile; ?>
    </ul>

    I’d like this to function like a normal menu — that is, the current page gets “current_page_item” class and is styled differently so you can tell you’re on the page. I tried adding an if ( ) statement into the line item like so:

    <ul class="side-nav">
    <?php
    $current = $post->ID ?>
    <?php
    $my_query = new WP_Query('post_type=page&post_parent=3&order=ASC');
     while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    <?php $image_thumb = get_post_meta($post->ID, 'image-thumb', true); ?>
    <li<?php if($current == $post->ID) { echo ' class="current_page_item"'; }?>><a href="<?php the_permalink(); ?>">
    
    <?php the_post_thumbnail(); ?>
    
    <?php the_title(); ?></a></li>
    		<?php endwhile; ?>
    </ul>

    All this does is return all the line items with class “current_page_item” … I figured that’s something to do with the new loop? Barg.

    I’m sure I’m doing something stupid wrong, or I’ve made this way too complicated. I’m fairly new at this kind of stuff …

    Thanks for any help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey Moolio,

    It’s allready a month ago but did you find a solution? I have the same desire using only post-tuhmbnails.

    Thanks

    Ha!

    Made it work.

    <ul>
      		<?php
    
                $args = array(
                    'post_type' => page,
                    'post_parent' => $post->ID,
     				'order' => ASC
               );
                query_posts($args);
    
    if ( has_post_thumbnail() ) {
    
    	} else {
    
    }
                 while (have_posts()) : the_post(); ?>
    
                      <li <?php if (is_page($post->ID)) { echo'class="current_page_item"'; } ?> id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a></li>
                    <?php endwhile; ?>
    
                    </ul>

    For anybody with the same request

    Thread Starter moolio

    (@moolio)

    Thanks juri003.

    I’ll give it a shot!

    werd.
    m.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘List of Subpages that works like a menu (with current_page_item class) ??’ is closed to new replies.