WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to stick a post in an archive.php (5 posts)

  1. FxB
    Member
    Posted 4 years ago #

    Hello,
    i made my menu with categories, so it open in an archive page.
    i'm looking for the query to make one or multi posts stick in an archive page without one more pluging please
    What do i have to put before my loop?
    I don't whant to change the date of the post to 2032 also
    thanks

    // retrieve one post with an ID of 182
    query_posts('p=182');
    ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post();?>
  2. vtxyzzy
    Member
    Posted 4 years ago #

    The only way I know to have sticky posts show at the top of an archive page is to code a separate loop for them.

    If you don't want them at the top you can use this code (UNTESTED):

    $sticky=get_option('sticky_posts') ;
    $sticky[] = 182;
    $args = array( 'post__in' => $sticky);
    query_posts($args);
  3. FxB
    Member
    Posted 4 years ago #

    thanks for the answer but i'm a noob in php

    in fact i'm looking to make 2 loops
    1) showing one post id=123 from the cat=1
    2) showing the rest of the post from the cat=1

    Something to do with multiple loops and query, does someone have a piece of code to save me.
    Thanks in advance

    my piece of code is not working and i don't know what to put after

    <?php
    // The Query - Customize!
    query_posts('showposts=5');
    // The Loop
    if (have_posts()) : while (have_posts()) : the_post();
    the_content();
    endwhile;
    else:
    <h2>Not Found</h2>
    endif;?>
  4. vtxyzzy
    Member
    Posted 4 years ago #

  5. FxB
    Member
    Posted 4 years ago #

    thank you, you made my day, i found the way

Topic Closed

This topic has been closed to new replies.

About this Topic