• Resolved J32

    (@j32)


    Hello everyone,

    I recently made a mistake and lost all the changes I made to a particular theme. As I try to redo everything I am missing a piece of code that I integrated in my index.php

    In my wordpress blog I had a particular post showing by ID and on the front page only.

    It was placed underneeth the regular list of posts and navigation for those. Like I said it appeared only on the first page. If you click to the next page to see older posts it wasn’t showing anymore.

    Now I found the code for this on a website, but I am not able to find the website anymore.

    Maybe somebody knows this website and can give me the url. Or if somebody has a code that does what I described it would be nice if you could post it here.

    thanks in advance for any help you guys can give me on this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I don’t have the website, but something like this should work:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    if ( $paged == 1 && is_front_page() ) :
       $postid = 123; // ID of the post to show
       $my_query = new WP_Query("p=$postid");
       while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
          <!-- Display the post -->
       <?php endwhile;
    endif; ?>
    Thread Starter J32

    (@j32)

    It is not the same code I had before but it does exactly what I wanted. Thank you so much. You made my day

    You are welcome!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘looking for code sticky post on frontpage only’ is closed to new replies.