Is there anyone that can help me out here please?! I'm not a WP guru..!

3 replies
  • WEB DESIGN
  • |
I switched to a new theme on one of my blogs, I've edited the code so everything looks good - and where/how I want everything to be displayed except for one DAMN thing!

I cannot for the life of me figure out how to have the MOST RECENT POST be displayed FIRST on the main index.php!! I haven't had any luck... This is the code from the themes original index.php. If I wrote a post today and stuck it on there... I want it to display first... This is ordering it all out of wack!

Plz someone.... Help! LOL! I usually don't ask for much help but I need it! 2nd time I've come posted a question here in less than a week! God I hate PHP! That's why I stick with HTML/CSS! :p

Thank you in advance!


HTML Code:
<!-- BEGIN content -->
<div id="content">
<?php
if (have_posts()) : the_post(); 
$arc_month = get_the_time('m');
$arc_day = get_the_time('d');
$arc_year = get_the_time('Y');
?>
<!-- begin recent post -->
<div class="recent post">
    <h2 class="title">Recent News</h2>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(''); ?>
</div>
<!-- end recent post -->
<?php else : ?>
<div class="notfound">
    <h2>Not Found</h2>
    <p>Sorry, but you are looking for something that is not here.</p>
</div>
<?php endif; ?>
<div class="posts">
<?php
if (have_posts()) :
while (have_posts()) : the_post(); 
$arc_month = get_the_time('m');
$arc_day = get_the_time('d');
$arc_year = get_the_time('Y');
?>
<!-- begin post -->
<div class="post">
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <a href="#"><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '" class="thumbnail"'); ?></a>
    <?php the_excerpt(); ?>
    <div class="details">
    <a href="<?php the_permalink(); ?>">READ MORE</a>
    <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>
    </div>
</div>
<!-- end post -->
<?php endwhile; endif; ?>
#guru
  • Profile picture of the author Istvan Horvath
    Well, the snippet you posted is not enough to judge where and what is screwed up...

    Normally, you don't need to do anything to have the latest/newest post displayed at the top of your main page (index of the theme).

    But if you meant to have the "most recent" (whatever else that means in your books) and another set of posts after/below that - it will make it more complicated because then you need multiple Loops.
    Signature

    {{ DiscussionBoard.errors[3276101].message }}
    • Profile picture of the author Patrick
      The following code will display the most recent posts in your index page..Just change the name of the classes

      Code:
      <?php if (have_posts()) : ?>
              <?php while (have_posts()) : the_post(); ?>
                  <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
                      <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                      <div class="postauthor"><small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small></div>
                      <div class="entry">
                          <?php the_content('Read the rest of this entry &raquo;'); ?>
                      </div>
                      <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
                  </div>
              <?php endwhile; ?>
              <div class="navigation">
                  <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
                  <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
              </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 get_search_form(); ?>
          <?php endif; ?>
      {{ DiscussionBoard.errors[3276120].message }}
      • Profile picture of the author scott g
        Thanks guys! I figured it out. My stupid a$$ installed a new plugin right around the time I edited and added the new theme... It had a option checked to re-circulate old post.... STUPID! I've been busing my a$$ too!

        CHEERS!
        Signature
        scott g
        "Whatever the mind can conceive and believe, the mind can achieve."

        {{ DiscussionBoard.errors[3276361].message }}

Trending Topics