• Resolved sepoto

    (@sepoto)


    //page.php
    <?php get_header(); ?>
    <div id=”primary”>

    <div id=”content” role=”main”>
    <?php the_post(); ?>
    <?php get_template_part( ‘content’, ‘page’ ); ?>
    <?php comments_template( ”, true ); ?>
    </div><!– #content –>

    </div><!– #primary –>
    <?php get_footer(); ?>

    With regards to the call to the_post();.. Why do I need to iterate for the loop on a page that is not supposed to really be using any posts? With regards to get_template_part… Can you really get part of the page template from page.php? Where is ‘content’ defined? Where is the code located that is fetched by get_template_part above? Those are my questions for the time being.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php get_template_part( ‘content’, ‘page’ ); ?>

    This section is defined your content. You don’t need to post individually <?php the_post(); ?>.

    Else you can do one thing … just remove …
    <?php get_template_part( ‘content’, ‘page’ ); ?>

    … And instead of that just paste there …..

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

    <h2><?php the_title(); ?></h2>
    <p><?php the_content();?></p>

    <?php endwhile; ?>

    And the_post() is different its located at wp-includes/query.php.

    So good luck.

    With regards to the call to the_post();.. Why do I need to iterate for the loop on a page that is not supposed to really be using any posts?

    Posts, pages, custom posts, and image details are all stored in the same table (wp-post) and a query or filter is created to return a dataset, either a single page or a set of posts, it is normal for database queries to work like this!, as there is only one page (wp-post) in the filter the loop is used to find the first, in posts it finds the first then next until the end of the dataset.

    With regards to get_template_part… Can you really get part of the page template from page.php? Where is ‘content’ defined?

    Template parts are blocks of code that you want included in the template, it is an advanced wrapper for the include statement, it takes two arguments, so get_template_part(‘content’,’category’) first looks for a file called content-category.php, if it can not find the file then content.php.

    Where is the code located that is fetched by get_template_part above? Those are my questions for the time being.

    Have a look in the twenty eleven theme at all the files starting “content-“, like content-page.php used in the page.php template.

    HTH

    David

    @srijan Mitra
    Why are you answering topics nine months later, I have just wasted time replying to this topics, which was likely resolved months ago!

    David ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Codex tea leaves. 2011 theme.’ is closed to new replies.