WordPress.org

Ready to get started?Download WordPress

Forums

display data in column (3 posts)

  1. sheme007
    Member
    Posted 5 years ago #

    Hi everybody,

    I've hacked the archive.php file, to display specific datas from posts :

    The posts are displayed like this :

    The title, custom field 1 and custom field 2

    By exemple :

    Paradise swimming pool, in Montpellier for 3-12 years old kids
    The activity park, in Paris for 4-16 years old kids
    ....

    I need to display this datas in columns (in a table) like this :

    Place to go______________________City__________________Kids age range

    Paradise swimming pool_________Montpellier__________________3-12
    The activity park__________________Paris____________________4-16

    Here is the code in the archive.php that displays these data

    <div class="single" id="post-<?php the_ID(); ?>">
    <div class="title">
    
    		<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Liens permanent vers <?php the_title_attribute(); ?>"><?php the_title(); ?></a> &agrave; <?php $values = get_post_custom_values("Lieu"); echo $values[0]; ?> pour les <?php $values = get_post_custom_values("min"); echo $values[0]; ?>/<?php $values = get_post_custom_values("max"); echo $values[0]; ?> ans</h3>
    
    	</div>
    </div>

    I'm not an expert, I tried with css class like inline but don't work
    I tried with a table but with no success....

    Thanks for your help !

    Got my excuse if my message is strange I'm french, and my english is approximative. On the french community there are message that stay for a very long time.... so I try here !

    Bye

  2. Michael Fields
    Themer
    Posted 5 years ago #

    Try this in your loop:

    <table>
    	<thead>
    		<th scope="col">Place to go</th>
    		<th scope="col">City</th>
    		<th scope="col">Kids age range</th>
    	</thead>
    		<tbody>
    		<tr id="post-<?php the_ID(); ?>">
    			<td><a href="<?php the_permalink() ?>" rel="bookmark" title="Liens permanent vers <?php the_title_attribute(); ?>"><?php the_title(); ?></a></td>
    			<td><?php $values = get_post_custom_values("Lieu"); echo $values[0]; ?> pour les <?php $values = get_post_custom_values("min"); echo $values[0]; ?></td>
    			<td><?php $values = get_post_custom_values("max"); echo $values[0]; ?></td>
    		</tr>
    	</tbody>
    </table>
  3. Michael Fields
    Themer
    Posted 5 years ago #

    Opps...
    You need to embed the loop in this code, try this instead:

    <table>
    	<thead>
    		<th scope="col">Place to go</th>
    		<th scope="col">City</th>
    		<th scope="col">Kids age range</th>
    	</thead>
    		<tbody>
    		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    		<tr id="post-<?php the_ID(); ?>">
    			<td><a href="<?php the_permalink() ?>" rel="bookmark" title="Liens permanent vers <?php the_title_attribute(); ?>"><?php the_title(); ?></a></td>
    			<td><?php $values = get_post_custom_values("Lieu"); echo $values[0]; ?> pour les <?php $values = get_post_custom_values("min"); echo $values[0]; ?></td>
    			<td><?php $values = get_post_custom_values("max"); echo $values[0]; ?></td>
    		</tr>
    		<?php endwhile; endif; ?>
    	</tbody>
    </table>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.