WordPress.org

Ready to get started?Download WordPress

Forums

Post and pages displayed at the front page after upgrade (8 posts)

  1. szimek
    Member
    Posted 7 years ago #

    Hi,

    I've installed version 2.07 3 days ago, so I'm a wordpress newbie.

    I've just upgraded to wordpress 2.1 and now I get post *and* pages displayed as posts on the front page (blog).

    I know that pages are in fact just posts in the database, but in blog stats I get correct number of posts and comments, so it still should work.

    I'm using broad leaf 1.5a theme, but I didn't change anything in the theme folder during upgrade.

    In index.php file there's the following loop:

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

    Does it distinguish posts from pages? Or maybe some other function should be used there?

  2. szimek
    Member
    Posted 7 years ago #

    I just added
    "AND (post_type = 'post') ".
    to the query and it works. Not sure how it could work before.

  3. nantucket
    Member
    Posted 7 years ago #

    szimek, can you give the full coding for where you placed the post type code you added above. do you include AND and where does the rest of it go? thanks

    <?php if ( have_posts() ) ...

  4. moshu
    Member
    Posted 7 years ago #

    Any theme that uses the regular Loop should work properly. the problem appears when certain themes are using a custom query for the posts in the index.
    I am not familiar with that theme - but that's my suspicion.

    You could paste your index.php to http://wordpress.pastebin.ca and post back the URI; somebody could take a look at your code.

  5. szimek
    Member
    Posted 7 years ago #

    I'm using broad leaf 1.5a theme - http://www.smackfoo.com/themes/broadleaf/. I turned out that it's using home.php, not index.php, but I couldn't edit my original message ("message is too old").

    So here's the original sql query from home.php:

    $myrecentposts = $wpdb->get_results(
    "SELECT DISTINCT * FROM $wpdb->posts, $wpdb->post2cat ".
    "WHERE post_date_gmt < '$today' ".
    "AND (post_status = 'publish') ".
    "AND $wpdb->posts.ID = $wpdb->post2cat.post_id ".
    "AND $wpdb->post2cat.category_id != '$side_cat' ".
    "GROUP BY $wpdb->posts.ID ".
    "ORDER BY post_date DESC ".
    "LIMIT 10 ");

    and here's modified version:

    $myrecentposts = $wpdb->get_results(
    "SELECT DISTINCT * FROM $wpdb->posts, $wpdb->post2cat ".
    "WHERE post_date_gmt < '$today' ".
    "AND (post_status = 'publish') ".
    "AND (post_type = 'post') ".
    "AND $wpdb->posts.ID = $wpdb->post2cat.post_id ".
    "AND $wpdb->post2cat.category_id != '$side_cat' ".
    "GROUP BY $wpdb->posts.ID ".
    "ORDER BY post_date DESC ".
    "LIMIT 10 ");

  6. Ajd777
    Member
    Posted 7 years ago #

    Before pages couldn't have a status of 'published' so it didn't matter, but with 2.1 pages can be 'drafts', 'private' or 'published' just like posts.

  7. szimek
    Member
    Posted 7 years ago #

    Thanks! Now it's clear why it worked before.

  8. moshu
    Member
    Posted 7 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic