Support » Fixing WordPress » Web page needs to select the most recent post

  • Resolved steve0701


    I inherited a web page at that looks fine, except that it pulls in the same two very old “news” articles every time. The index.htm file is way too short to generate all the content on the page, but if you click your browser to see the source there are about 238 lines that tell the whole story- if you understand WordPress, which I do not. Two questions: can you find where the old posts are called in? Can you tell me how to call in the one or two of the most


    posts, instead? Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Steve, I can’t tell by looking at the page, but it may be that the posts in question are marked ‘sticky’ to keep them on the home page.

    If you are running WP 2.8.+, go to Posts->Edit in the Dashboard, and if the title of the post shows ‘-Sticky’, you can Quick Edit the post and clear the ‘Make this post sticky’ checkbox.

    The content of the page is not going to be found in an index file on your server…rather WordPress is dynamically pulling the information from those two posts from its database.

    (Good point kymac about them being sticky posts, but it looks like they’re pulling in the two most recent posts from the news category.)

    In index.php (or home.php) look for something that says query_posts(cat=3) or new WP_Query(cat=3)…the cat=3 tells WP to only include posts from your “News” category and from that point until the <?php endwhile; ?> is what controls how those posts are formated (what is displayed and the html around them). To show the most recent posts from the entire site just remove the cat=3.

    To edit the actual posts, go to /wp-admin/edit.php and click on the post titles that you want to edit.

    Good try guys, but none of the posts were sticky, and every post already has the same category (news). I found that I can mark the newest post sticky and it shows up ahead of the 2 old posts. I even tried to sticky and unsticky the old, unwanted posts to no avail. Any other ideas? Is there any way I might be instructing WP to present the 2 OLDEST posts?

    but none of the posts were sticky, and every post already has the same category (news)
    — strange…your “News” RSS feed ( doesn’t seem to be matching your “News” category page ( can you post the contents of the page template used for your /cms page?

    — also, are there any tags or other categories selected for this post –> ?

    Thanks for the reply. I am going to paste the content from the index.php located in our custom theme/template. Pardon all the gibberish code, but this is a hopeless situation for me. Does any of this help?

    <?php get_header(); ?>

    <div class=”box”>

    <?php include(“../news/head_news.htm”) ?>

    <div class=”column_left”>
    <?php include(“../navigation.htm”) ?>

    <div> </div>
    <div align=”center”>
    <!–<script type=”text/javascript”><!–
    google_ad_client = “pub-8252063556694168”;
    google_ad_width = 120;
    google_ad_height = 240;
    google_ad_format = “120x240_as”;
    google_ad_type = “text_image”;
    google_ad_channel = “”;
    google_color_border = “336699”;
    google_color_bg = “FFFFFF”;
    google_color_link = “0000FF”;
    google_color_text = “000000”;
    google_color_url = “008000”;
    google_ui_features = “rc:0”;
    <script type=”text/javascript”
    </script> –>


    <div class=”column_full”>

    <div class=”block_top”>What’s Happening</div>

    <div class=”block”>

    <div id=”content” class=”narrowcolumn”>

    <?php if (have_posts()) : ?>

    <?php $offset = ($paged) ? (int) (get_option(‘posts_per_page’) * ($paged – 1)) : 0; ?>
    <?php query_posts(“orderby=menu_order&order=ASC&offset={$offset}”); ?>

    <?php while (have_posts()) : the_post(); ?>

    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></h2>
    <small><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></small>

    <div class=”entry”>
    <?php the_content(‘Read the rest of this entry »’); ?>

    <p class=”postmetadata”><?php the_tags(‘Tags: ‘, ‘, ‘, ‘
    ‘); ?> Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(‘No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></p>

    <hr />

    <?php endwhile; ?>

    <div class=”navigation”>
    <div class=”alignleft”><?php next_posts_link(‘« Older Entries’) ?></div>
    <div class=”alignright”><?php previous_posts_link(‘Newer Entries »’) ?></div>

    <?php else : ?>

    <h2 class=”center”>Not Found</h2>
    <p class=”center”>Sorry, but you are looking for something that isn’t here.</p>
    <?php include (TEMPLATEPATH . “/searchform.php”); ?>

    <?php endif; ?>


    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

    <div class=”block_bottom”></div>


    <?php include(“../foot.htm”) ?>


    Based on the xhtml markup that looks like the correct template.

    In index.php change:

    <?php if (have_posts()) : ?>
    <?php $offset = ($paged) ? (int) (get_option('posts_per_page') * ($paged - 1)) : 0; ?>
    <?php query_posts("orderby=menu_order&order=ASC&offset={$offset}"); ?>
    <?php while (have_posts()) : the_post(); ?>


    <?php if (have_posts()) : ?>
    <?php /* $offset = ($paged) ? (int) (get_option('posts_per_page') * ($paged - 1)) : 0;*/ ?>
    <?php /*query_posts("orderby=menu_order&order=ASC&offset={$offset}");*/ ?>
    <?php while (have_posts()) : the_post(); ?>

    and see if that fixes the issue.

    Commenting those 2 lines prevented the page from loading. Message: Parse error: parse error, unexpected $ in /home/content/d/e/l/delcospca/html/cms/wp-content/themes/mytheme/index.php on line 46

    No harm done. Any more ideas?

    unexpected $ in wp-content/themes/mytheme/index.php on line 46

    — Did you put the opening /* comment tag in front of the $? I’m not seeing another $ after the line that begins with $offset

    — Can you post just line 46 from index.php?

    — Also try separating the comments further out so we know we’re casting a wide enough net:

    <?php if (have_posts()) : ?>
    <?php /*
    <?php $offset = ($paged) ? (int) (get_option('posts_per_page') * ($paged - 1)) : 0; ?>
    <?php query_posts("orderby=menu_order&order=ASC&offset={$offset}"); ?>
    */ ?>
    <?php while (have_posts()) : the_post(); ?>

    Success! When you mentioned the OPENING comment tag it tipped me off that there must be such a thing as a CLOSING comment tag. Yep, I never looked beyond the opening tag. Seems like I still think we are in the world of COBOL or BASIC. Thank you for all your help.

    Good to hear. Can you mark this ticket as resolved?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Web page needs to select the most recent post’ is closed to new replies.