• I’m trying to make a very simple page and I’m not sure if I’m supposed to take the Loop into account when I do that.

    Here is the code I have:

    <?php get_header() ?>
    
    <?php the_post() ?>
    
    <?php the_content() ?>
    
    <?php get_footer() ?>

    Is this the simplest way possible to have content displaying on a page?

    Basically all I want is:

    = Header =
    = Content =
    = Footer =

    So I’m thinking all I actually need is:

    <?php get_header() ?>
    
    <?php the_content() ?>
    
    <?php get_footer() ?>

    Is this right?

    Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter onethousandseas

    (@onethousandseas)

    I did actually but I wasn’t sure if I had understood it correctly, which was why I pasted that bit of sample code. It seemed like that article was directed more towards blog entries than static pages.

    Thread Starter onethousandseas

    (@onethousandseas)

    I should also add that I’m trying to pare it down to be as brutally minimalist as possible, so I can figure out what I’m doing. If someone could verify that what I have up above is still valid, that would be great.

    what dont you understand? I pointed you the those pages because what you have is NOT right. That ought to be obvious if you compare what you have to what is described in the codex.

    Please review the links I pointed you to again.

    Thread Starter onethousandseas

    (@onethousandseas)

    No.

    It’s not obvious. As it’s clearly not obvious to you that I’m a total beginner at this. I can of course compare the code on those pages and see that it’s not the same. Where I’m having trouble is what this all means and where I’m supposed to go next. And while those pages do a great job of explaining to someone who probably knows what they’re doing, I’m not that person. Which is why I’m asking questions here.

    the codex exists to show you what you need. You want someone here to do what? provide the same thing thats on the codex? FOR WHAT?

    ok, Fine, heres me regurgitating whats on the codex:

    The loop starts here:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    and ends here:

    <?php endwhile; else: ?>
    <p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p>
    <?php endif; ?>

    Heres some more regurgitation:

    The World’s Simplest Index Page

    The following is a fully functional index which will display the contents (and just the contents) of each post, according to the conditions used to prepare The Loop. The only purpose for showing you this is to demonstrate how little is actually necessary for the functioning of The Loop. The bulk of the stuff in your index.php is CSS, HTML, and PHP declarations to make The Loop look pretty.

    <?php
    get_header();
    if (have_posts()) :
       while (have_posts()) :
          the_post();
          the_content();
       endwhile;
    endif;
    get_sidebar();
    get_footer();
    ?>

    It doesnt get any simpler, ffs. compare what you have up there to whats right above! edit as necessary.

    Thread Starter onethousandseas

    (@onethousandseas)

    Yeah, while we’re FFSing then:

    1. FFS what’s the difference between that index page and a regular Page? Is it none?

    2. FFS while I get that a Page is still dynamically generated, I still don’t understand what the Loop has to do with all this. What the hell is it Looping onto a regular Page?

    Never mind, I answered my own second question while I was typing it up. Apparently the answer seems to be: it’s not dated, doesn’t chronologically link to anyplace else on the site, and doesn’t look like a blog. Fine and dandy.

    I still don’t understand what the Loop has to do with all this. What the hell is it Looping onto a regular Page?

    if you bothered to read:

    The Loop is used by WordPress to display each of your posts. Using The Loop, WordPress processes each of the posts to be displayed on the current page and formats them according to how they match specified criteria within The Loop tags. Any HTML or PHP code placed in the Loop will be repeated on each post. When WordPress documentation states “This tag must be within The Loop”, such as for specific Template Tag or plugins, the tag will be repeated for each post.

    the_content is one such tag that MUST be used within the loop.

    Thread Starter onethousandseas

    (@onethousandseas)

    The basic question underlying all this that I eventually learned I should be asking was:

    Is a page a post?

    Which apparently it was.

    And that’s all I really needed to know.

    Wow. wasn’t that a fun read.

    As another newbie, I can understand your question, Seas. I’m asking the same ones, and am reading and re-reading The Loop posts with every step.
    I’m think of a capital-P Page as a page with one post attached to it. So the reason you couldn’t use your first example is that you didn’t loop through to find and display that one post. And you can’t really call the_content() without the database recognizing what post you’re referring to.

    JA

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Question about The Loop in pages’ is closed to new replies.