Forums

styling a category page (3 posts)

  1. finbarr1987
    Member
    Posted 1 year ago #

    Hey I'm not sure how to do this was wondering if somebody could help,

    I have a parent page showing excerpts from its child page,
    I want to style them as a ul with each excerpt as a list item,

    But the

    <li> are inside just one </li>
    <li> of and don't act as separate </li>
    <li>

    Here is the code,

    <ul class="cat">
    
    <li>	<?php
    	$child_pages = $wpdb->get_results("SELECT *  FROM $wpdb->posts WHERE post_parent = ".$post->ID."   AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); ?>
    
    	<?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
    	<h2 class="subpagetitle">
    
    		<a href="<?php echo  get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php echo $pageChild->post_title; ?>">
    
    <img style="float:left;margin: 0 10px 10px 0;border:1px solid #000;height:90px" src="<?php $child_pages = get_post_custom_values("Image"); echo $values[0]; ?>" alt="thumbnail" height="90" />
    
    <?php echo $pageChild->post_title; ?></a></h2>
    
    	<?php the_excerpt();?>
    	<?php endforeach; endif;
    
    	?></li>
    
    </ul>

    and the css

    ul.cat {
    			width:100%;
    			display: block;
    
    		padding:20px 0 0 0;
    
    	}
    
    	ul.cat li {
    		width:300px;
    float:left;
    
    	}

    Thanks in advance for your help!

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    you need to move the <li> and </li> to inside of the foreach loop; for instance:

    <ul class="cat">
    
    	<?php
    	$child_pages = $wpdb->get_results("SELECT *  FROM $wpdb->posts WHERE post_parent = ".$post->ID."   AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); ?>
    
    	<?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
    	<li> <h2 class="subpagetitle">
    
    		<a href="<?php echo  get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php echo $pageChild->post_title; ?>">
    
    <img style="float:left;margin: 0 10px 10px 0;border:1px solid #000;height:90px" src="<?php $child_pages = get_post_custom_values("Image"); echo $values[0]; ?>" alt="thumbnail" height="90" />
    
    <?php echo $pageChild->post_title; ?></a></h2>
    
    	<?php the_excerpt();?>
    </li>
    	<?php endforeach; endif; ?>
    </ul>

    (untested)

  3. finbarr1987
    Member
    Posted 1 year ago #

    Brilliant!
    Thanks Very much!

Topic Closed

This topic has been closed to new replies.

About this Topic