WordPress.org

Support

Support » How-To and Troubleshooting » Post and pages displayed at the front page after upgrade

Post and pages displayed at the front page after upgrade

  • 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?

Viewing 7 replies - 1 through 7 (of 7 total)
  • I just added
    "AND (post_type = 'post') ".
    to the query and it works. Not sure how it could work before.

    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() ) …

    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.

    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 ");

    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.

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Post and pages displayed at the front page after upgrade’ is closed to new replies.
Skip to toolbar