WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post Title v. Page Title (18 posts)

  1. hoss9009
    Member
    Posted 3 years ago #

    For some reason my loop is calling in ANY posts. It shows only the title of the page where the loop is supposed to be.
    Here's my loop:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2><a href="<?php the_permalink(); ?>"
    rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <?php echo get_post_meta($post->ID, 'PostThumb',true); ?>
    <p class="meta">
    <span>Posted on</span> <?php the_time('F jS,Y'); ?> <span>by</span> <?php the_author(); ?>
    </p>
    <?php the_content('Read Full Article'); ?>
    <p><?php the_tags('Tags: ', ', ', '<br />'); ?>
    Posted in <?php the_category(', '); ?>
    <?php comments_popup_link('No Comments;',
    '1 Comment', '% Comments'); ?></p>
    </div>
    <?php endwhile; ?>
    <?php next_posts_link('Older Entries'); ?>
    <?php previous_posts_link('Newer Entries'); ?>
    <?php else : ?>
    <h2>Nothing Found</h2>
    <?php endif; ?>

    Any ideas?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Try commenting out <?php echo get_post_meta($post->ID, 'PostThumb',true); ?> and see if that helps.

  3. hoss9009
    Member
    Posted 3 years ago #

    Tried that... I've started commenting out different parts... same problem.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    It could be something before that code that's messing things up. Maybe another Loop in another template that's being loaded earlier?

  5. hoss9009
    Member
    Posted 3 years ago #

    nope.
    Here's my header

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
    <link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" />
    <link href="<?php bloginfo('template_url'); ?>/pages.css" rel="stylesheet" type="text/css"  />
    </head>
    <body>
    <div id="wrap">
    
    <div id="header">
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.min.js"></script>
    <script src="<?php bloginfo('template_url'); ?>/js/droplinemenu.js" type="text/javascript"></script>
    <script type="text/javascript">
    //build menu with DIV ID="myslidemenu" on page:
    droplinemenu.buildmenu("menu-rcdnav")
    </script>
    
    <div id="menu-rcdnav" class="droplinebar">
    <ul>
    <li><a href="<?php echo get_option('home'); ?>/" id="home">Home</a></li>
    <li class="divider"><a href="<?php echo get_option('home'); ?>/our-work/" id="work"><span class="alt">Our Work</span></a>
          <ul>
            <li><a href="<?php echo get_option('home'); ?>/our-work/web-interactive/">Web & Interactive</a></li>
            <li><a href="<?php echo get_option('home'); ?>/our-work/print-packaging/">Print & Packaging</a></li>
            <li><a href="<?php echo get_option('home'); ?>/our-work/branding-identity/"class="left-end">Branding & Identity</a></li>
          </ul>
    </li>
    <li class="divider"><a href="<?php echo get_option('home'); ?>/company/" id="company"><span class="alt">Company</span></a>
          <ul>
            <li><a href="<?php echo get_option('home'); ?>/company/how-we-work/">How We Work</a></li>
            <li><a href="<?php echo get_option('home'); ?>/company/services/">Services</a></li>
            <li><a href="<?php echo get_option('home'); ?>/company/experience/">Experience</a></li>
            <li><a href="<?php echo get_option('home'); ?>/company/about-us/" class="left-end">About Us</a></li>
          </ul>
    </li>
    <li class="divider"><a href="<?php echo get_option('home'); ?>/news/" id="news"><span class="alt">News</span></a></li>
    <li class="divider"><a href="<?php echo get_option('home'); ?>/contact/" id="contact"><span class="alt">Contact</span></a></li>
    </ul>
    </div>
    
    <!-- end "nav" -->
    </div>
    <!-- end "header" -->
  6. hoss9009
    Member
    Posted 3 years ago #

    Here's the page I'm working on...

    <?php
    /*
    Template Name: News
    */
    ?>
    <?php get_header(); ?>
    <div id="content">
    <div id="red-news"></div>
    <div id="left">
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post">
    <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <p class="meta">
    <span>Posted on</span> <?php the_time('F jS,Y'); ?> <span>by</span> <?php the_author(); ?>
    </p>
    <?php the_content('Read Full Article'); ?>
    </div>
    <?php endwhile; ?>
    <?php next_posts_link('Older Entries'); ?>
    <?php previous_posts_link('Newer Entries'); ?>
    <?php else : ?>
    <h2>Nothing Found</h2>
    <?php endif; ?>
    
    <div class="clear"></div>
    </div><!-- end id="left" -->
    <?php include (TEMPLATEPATH . '/blog-sidebar.php'); ?>
    <div class="clear"></div></div><!-- end "content -->
    <?php get_footer(); ?>
  7. hoss9009
    Member
    Posted 3 years ago #

    The blog-sidebar.php has this:
    <?php wp_get_archives('type=postbypost&limit=5'); ?>

    That couldn't be it, could it?

  8. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Hang on! This is a custom template, so I assume you're trying to pull in specific posts, yes? In which case you need to define which posts you want using query_posts.

  9. hoss9009
    Member
    Posted 3 years ago #

    no... not wanting to pull in any specific posts... I was wanting to use this tho.
    But I haven't put it in yet.

    Wait... should I have saved this page as index.phpand then use the Settings>Reading settings to change the front page and the blog page?
    Does the index.phponly read the traditional loop?

  10. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    not wanting to pull in any specific posts

    But if it's a page template, it will only pull the content for the page it's been associated with (ie the stuff types in via Edit Page) - unless you add a custom query.

    What's the template intended to be used for?

  11. hoss9009
    Member
    Posted 3 years ago #

    Just to show ALL my posts.

  12. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Then you either need to use this code in index.php or you need to set up a custom query.

  13. hoss9009
    Member
    Posted 3 years ago #

    Wow... 2 years w/ wp and I never realized this. Danke

  14. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    You're welcome. :-)

  15. hoss9009
    Member
    Posted 3 years ago #

    @esmi,

    So I have another problem. How do I structure (keyword) the loop so that the first post looks different than the rest.
    Like I said earlier, I found some code that could help me add class(es) to the first post, but I don't know how to get it the way that I want.

    I was thinking about something like this, but I think I run into issues of how things look on the pages of posts AFTER the first page of posts:

    <?php // Beginning of the loop ?>
    <?php if ( $paged < 2 ) { ?>
    <?php
    $latestPost = new WP_Query();
    $latestPost->query('posts_per_page=1');
    while ($latestPost->have_posts()) : $latestPost->the_post(); ?>
    <div id="red-news"></div>
    <div id="left">
    <div class="latest-post"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <div class="date"><span class="month"><?php the_time('M') ?></span><span class="day"><?php the_time('j') ?></span><span class="year"><?php the_time('Y') ?></span></div>
    <div class="thumbnail"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail('latest'); ?></a></div>
    <div class="entry"><?php the_excerpt(); ?><div class="read-more"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">read more ></a></div>
    </div><div class="clear"></div><div class="clear"></div></div><!-- end LATEST POST --><?php endwhile; ?>
    
    <?php
    $latestPost = new WP_Query();
    $latestPost->query('posts_per_page=2&offset=1' . '&paged=' . get_query_var('paged'));
    while ($latestPost->have_posts()) : $latestPost->the_post(); ?>
    <div class="post">
    <div class="date"><span class="month"><?php the_time('M') ?></span><span class="day"><?php the_time('j') ?></span><span class="year"><?php the_time('Y') ?></span></div>
    <div class="thumbnail"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a></div>
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <div class="entry"><?php the_excerpt(); ?>
    <div class="read-more"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">(...)</a></div>
    </div>
    <div class="clear"></div>
    </div><!-- end POST -->
    <?php endwhile; ?>
    
    <div id="pagination"><?php wp_pagenavi(); ?></div>
    
    <?php //This is the dividing line - Above: First page of the blog / Below: All the other pages ?>
    <?php } else { ?>
    
    <?php
    $latestPost = new WP_Query();
    $latestPost->query('posts_per_page=3&offset=3' . '&paged=' . get_query_var('paged'));
    while ($latestPost->have_posts()) : $latestPost->the_post(); ?>
    <div class="post">
    <div class="date"><span class="month"><?php the_time('M') ?></span><span class="day"><?php the_time('j') ?></span><span class="year"><?php the_time('Y') ?></span></div>
    <div class="thumbnail"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a></div>
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <div class="entry"><?php the_excerpt(); ?>
    <div class="read-more"><a href="#">(...)</a></div>
    </div>
    <div class="clear"></div>
    </div><!-- end POST -->
    <?php endwhile; ?>
    
    <?php } ?>
    <?php // end "if 1st and 2nd page code ?>

    Again, this is the OLD code. The original purpose of starting this thread was to get the traditional loop going (which I did), but I still have all the posts looking the same. There's gotta be an easy way to fix this. Any ideas?
    Anything would be GREATLY appreciated.

    -hoss

  16. hoss9009
    Member
    Posted 3 years ago #

    If anyone else has any ideas, I would greatly appreciate it.

  17. hoss9009
    Member
    Posted 3 years ago #

  18. hoss9009
    Member
    Posted 3 years ago #

    It works!!!!!!!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.