Support » Fixing WordPress » How to Generate contents

  • Resolved taghaboy

    (@taghaboy)


    Hi all,
    i’d like to know how to generate this line of table <tr> under the loop in a template

    <tr>
    	<td><?php the_ID(); ?></td>
    	<td><?php the_title(); ?></td>
    	<td><?php the_category(', ') ?></td>
    	<td><?php the_date(); ?></td>
    	<td><?php the_author(); ?></td>
    	<td><a href="<?php the_permalink(); ?>">More...</a></td>
    </tr>

    and this my try – Not work

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <tr>
    	<td><?php the_ID(); ?></td>
    	<td><?php the_title(); ?></td>
    	<td><?php the_category(', ') ?></td>
    	<td><?php the_date(); ?></td>
    	<td><?php the_author(); ?></td>
    	<td><a href="<?php the_permalink(); ?>">More...</a></td>
    </tr>
    <?php endwhile; endif; ?>

    Thanks in Advance.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Forgive me, but why you want use tables for this?

    my try – Not work

    What does not work? Errors? No display?

    Hi Evita, and thanks for reply.
    It display any error, it just print only the latest news (one line), and i want to display all the news data (ID, Title, Cat…) in lines.
    That’s why i’d like to know to generate this line of table <tr>.
    Thanks.

    And why do you think you need tables for that? You can do anything you want (if you know HTML and CSS) without any table.

    moshu, (with my respect to you, YOU NEVER PROVIDE A HELP TO ME IN MANY TOPIC I OPEN, YOU ONLY TALK… i hop you only provide a TIP it well be more easy to solve this amazing code who any board in the net provide a solution)
    WHY DO I NEED TABLE?????
    Cause i use the tablesorter with it, users can sort all news by Author, Date , or category…
    THAT’S WHY I NEED THIS LINE TO BE GENERATED.
    and i hop you provide help if possible, if not, it’s better do not writ nothing.

    Do you have an opening <table> and closing </table> somewhere for that table of yours? I don’t see it.

    I put that code of your (after adding the missing table tags) and it shows up as it should.

    Yes i Do, i just past the part i need, and this is the code with table tag:

    <table>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <tr>
      <td><?php the_ID(); ?></td>
      <td><?php the_title(); ?></td>
      <td><?php the_category(', ') ?></td>
      <td><?php the_date(); ?></td>
      <td><?php the_author(); ?></td>
      <td><a href="<?php the_permalink(); ?>">Lire plus...</a></td>
    </tr>
    <?php endwhile; endif; ?>
    </table>

    The result i have is only one line generated, especially the lastest news dada.

    Thanks

    i’d like to note that this script it’s using under a table.php as a tempalte i attached with a page.

    As moshu said, the code should work, it´s a simple table.
    Maybe you have to give your td a width or you have some annoying code in your stylesheet.
    Sorry, this was not very helpul.

    hi again Evita,
    the table work in the home page, but it dont work in the Page (it show only the lastest news data)???
    is there a different loop structur between Postes and Pages?

    There isn’t. But WP knows exactly whether you are on a Page or on a multipost view (like index, archives etc.); and on Pages it displays by default only one entry.

    I have NO idea, but is this a clue (taken from your link to tablesorter)

    “turning a standard HTML table with THEAD and TBODY tags into a sortable table”

    I see no THEAD or TBODY in your code

    @earner: her the complet code i use.
    ——Tips———-
    And for users who want to use it, must download and learn Tablesorter Documentation, it better to let users parse and sort many types of data including linked data in a cell.
    ——————–

    <table cellspacing="1" class="tablesorter">
    <thead>
    	<tr>
    		<td>ID</td>
    		<td>Title</td>
    		<td>Category</td>
    		<td>Date</td>
    		<td>Author</td>
    		<td>Link</td>
    	</tr>
    </thead>
    <tbody>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    	<tr>
    		<td><?php the_ID(); ?></td>
    		<td><?php the_title(); ?></td>
    		<td><?php the_category(', ') ?></td>
    		<td><?php the_date(); ?></td>
    		<td><?php the_author(); ?></td>
    		<td><a href="<?php the_permalink(); ?>">more</a></td>
    	</tr>
    <?php endwhile;?>
    </tbody>
    </table>

    ________________

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to Generate contents’ is closed to new replies.