Show a specified entrie (15 posts)

  1. Martin-FR
    Posted 9 years ago #


    How can I show the entrie ID 1 in my index.php ? What is the code ?

    Thanks !

  2. Martin-FR
    Posted 9 years ago #

    I want to show the post ID 1 in first in my index.php How can I do that ?

  3. PozHonks
    Posted 9 years ago #


    More details, here:

    Or, if you wish to put a post always on top of a list, use the Adhesive plug-in: http://redalt.com/wiki/Adhesive

  4. Martin-FR
    Posted 9 years ago #

    I don't know how do that. Can you put the code into my index.php ?

    [code]<?php get_header(); ?>

    <div id="page_container">

    <?php get_sidebar(); ?>
    <?php include (TEMPLATEPATH . '/leftbar.php'); ?>

    <div id="postcol" class="fixheight">
    <div id="pc_t" class="fixheight">
    <div id="pc_r" class="fixheight">
    <div id="pc_b" class="fixheight">
    <div id="pc_l" class="fixheight">
    <div id="pctl" class="fixheight">
    <div id="pctr" class="fixheight">
    <div id="pcbr" class="fixheight">
    <div id="pcbl" class="fixheight">
    <div id="pc_c" class="fixheight">
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="postbox">
    <div class="right">
    <div class="bottom">
    <div class="left">
    <div class="post_title">
    <div class="top">
    <div class="right">
    <div class="left">
    <div class="tl">
    <div class="tr">
    <h2 id="post-<?php the_ID(); ?>" class="title">" rel="bookmark" title="Lien pour l'article <?php the_title(); ?>"><?php the_title(); ?></h2>
    <small class="title">Posté par <?php the_author() ?> le <?php the_time('j F Y') ?></small>
    </div></div></div></div></div></div> <?php /* post_title */ ?>
    <div class="br">
    <div class="bl">
    <div class="content">
    <?php the_content('Lire la suite »'); ?>
    <p class="postmetadata"> <?php the_category(', ') ?> | <?php edit_post_link('Editer','',' | '); ?><?php comments_popup_link('Aucun commentaire »', 'Un commentaire »', '% commentaires »'); ?>
    </div></div></div></div></div></div></div> <?php /* postbox */ ?>
    <?php endwhile; ?>
    <div class="navigation">
    <div class="alignleft"><?php posts_nav_link('','','« Article précédent') ?></div>
    <div class="alignright"><?php posts_nav_link('','Article suivant »','') ?></div>
    </div> <?php /* navigation */ ?>
    <div style="clear: both"></div>
    <?php else : ?>
    <h2 class="center">Introuvé - Not Found</h2>
    <p class="center"><?php _e("Désolé, cette page n'existe pas."); ?>
    <?php endif; ?>
    <?php get_footer(); ?>

  5. PozHonks
    Posted 9 years ago #

    Place this before what we call The Loop http://codex.wordpress.org/The_Loop which is:
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    So, it must be:
    <?php query_posts('p=1'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

  6. Martin-FR
    Posted 9 years ago #

    Okay !
    And if I want to show the post ID 1 and the post ID 4. What's the code ?

    Thanks !

  7. moshu
    Posted 9 years ago #

    You could also use this plugin:

  8. Martin-FR
    Posted 9 years ago #

    Yes but it doesn't make the same style as the post.

    PS : I'm french...

  9. moshu
    Posted 9 years ago #

    OK, I am not a native English speaker either :)
    I've never had any style problems with that plugin - if your answer was directed to me. On the contrary! You can put the plugin call (code) in a different div and have it styled as you wish. But normalyy it would just display the selected post/Page in the general layout of the theme.

  10. Martin-FR
    Posted 9 years ago #

    Yes, I put this code :

    <?php get_a_post(1); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>

    It is not the same style.
    See this page : http://www.trains-idf.net/wordpress
    The first post is normally the same as the third, but it is not the same style.

  11. PozHonks
    Posted 9 years ago #

    If you want to display the same content in the home page (only 2 or 3 posts, a welcome, etc.), you should create a static home page. 2 methods. The simplest one with a plug-in http://www.semiologic.com/software/static-front/ where you write a Page (not a post), put your welcome message, and with the help of this plug-in, tell WordPress to display it as the home page.
    Or, create a home.php file. WordPress will automatically displaid it as the home page. Copy the content of the index.php file, copy it into home.php, search for The Loop http://codex.wordpress.org/The_Loop and put the code you want, as explained here http://codex.wordpress.org/Creating_a_Static_Front_Page

    You will have more control and it will be easier to customize.

  12. Martin-FR
    Posted 9 years ago #

    It doesn't work. Can you insert the code in the home.php ? The code from index.php is above.

    Thanks !!!! :D

  13. PozHonks
    Posted 9 years ago #

    It must work. A simple copy of the index.php renamed to home.php must work. Then, WordPress call home.php first as the home page.
    Or, use the plug-in instead.

  14. Martin-FR
    Posted 9 years ago #

    Yes, it work but I don't know what is the code I must insert. http://codex.wordpress.org/Creating_a_Static_Front_Page

    Instead of doing that, I can put the code which show posts in an ascending order and then limit at 1 post. It will show the first article only. (that is what I want)
    Is it possible ? What is the code ?

  15. PozHonks
    Posted 9 years ago #

    This plug-in: http://www.semiologic.com/software/static-front/
    It is so easy that you must succeed ! ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic