WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to Generate contents (13 posts)

  1. taghaboy
    Member
    Posted 5 years ago #

    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.

  2. Evita
    Member
    Posted 5 years ago #

    Forgive me, but why you want use tables for this?

    my try - Not work

    What does not work? Errors? No display?

  3. taghaboy
    Member
    Posted 5 years ago #

    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.

  4. moshu
    Member
    Posted 5 years ago #

    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.

  5. taghaboy
    Member
    Posted 5 years ago #

    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.

  6. moshu
    Member
    Posted 5 years ago #

    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.

  7. taghaboy
    Member
    Posted 5 years ago #

    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

  8. taghaboy
    Member
    Posted 5 years ago #

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

  9. Evita
    Member
    Posted 5 years ago #

    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.

  10. taghaboy
    Member
    Posted 5 years ago #

    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?

  11. moshu
    Member
    Posted 5 years ago #

    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.

  12. earner
    Member
    Posted 5 years ago #

    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

  13. taghaboy
    Member
    Posted 5 years ago #

    @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>

    ________________

Topic Closed

This topic has been closed to new replies.

About this Topic