• After upgrading to WP 3.4 a template I use to display all posts in an archive list format stopped working. Any tips?

    <?php get_header(); ?>
    <?php
    /*
    Template Name: All posts
    */
    ?>
    <?php
    $debut = 0; //The first article to be displayed
    ?>
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <ul>
    <?php
    $myposts = get_posts('numberposts=-1&offset=$debut');
    foreach($myposts as $post) :
    ?>
    <li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    
    <?php get_footer(); ?>
    <?php endwhile; ?>
Viewing 9 replies - 1 through 9 (of 9 total)
  • When you say stop working do you mean they’re not showing up, or do you mean the page isn’t loading anymore?

    jack randall

    (@theotherlebowski)

    i have an idea:

    move <?php get_header(); ?>

    to

    <?php
    /*
    Template Name: All posts
    */
    ?>
    <?php get_header(); ?>

    and see if that makes a difference. the php template name code has to come before anything else to let wp know what the file is. (i think… i may sit corrected!)

    Thread Starter andreleibovici

    (@andreleibovici)

    Thanks for that, but didn’t work.
    I am now using the code below but the page is empty.
    Any other suggestions?

    <?php
    /*
    Template Name: All posts
    */
    ?>
    <?php get_header(); ?>
    <?php
    $debut = 0; //The first article to be displayed
    ?>
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <ul>
    <?php
    $myposts = get_posts('numberposts=-1&offset=$debut');
    foreach($myposts as $post) :
    ?>
    <li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    
    <?php get_footer(); ?>
    <?php endwhile; ?>
    jack randall

    (@theotherlebowski)

    try putting this

    <?php endwhile; ?>

    above

    <?php get_footer(); ?>

    Thread Starter andreleibovici

    (@andreleibovici)

    I am still getting blank page, even after cache refresh.
    Interesting is that it was working prior to upgrade.

    <?php
    /*
    Template Name: All posts
    */
    ?>
    <?php get_header(); ?>
    <?php
    $debut = 0; //The first article to be displayed
    ?>
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <ul>
    <?php
    $myposts = get_posts('numberposts=-1&offset=$debut');
    foreach($myposts as $post) :
    ?>
    <li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    <?php endwhile; ?>
    <?php get_footer(); ?>
    jack randall

    (@theotherlebowski)

    did you deactivate all your plugins prior to upgrading?

    Thread Starter andreleibovici

    (@andreleibovici)

    No, I have not disabled all plugins before upgrading.
    Is it too late?

    Thread Starter andreleibovici

    (@andreleibovici)

    It seems to be an issue with get_posts. If I specify the number of posts get_posts(‘numberposts=300’) it seems to work. If I do not specify to list all posts get_posts(‘ ‘) it doesn’t work. If I use get_posts(‘numberposts=-1&offset=$debut’) also doest’t work.

    The code below works but even like that not all posts are listed.

    <?php get_header(); ?>
    <?php
    /*
    Template Name: All posts
    */
    ?>
    
    <?php
    $debut = 0; //The first article to be displayed
    ?>
    
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    
    <ul>
    <?php
    $myposts = get_posts('numberposts=300');
    foreach($myposts as $post) :
    setup_postdata($post);
    
    ?>
    <li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; wp_reset_postdata(); ?>
    </ul>
    
    <?php get_footer(); ?>
    <?php endwhile; ?>
    jack randall

    (@theotherlebowski)

    you should always deactivate all plugins before you upgrade the core wordpress installation as not every plugin is ready for the new wordpress core code.

    go into your servers cpanel (or equivalent) and navigate to the plugins folder in the wordpress core and rename it plugins_old and then head back to your site, refresh (clear cache too) and see if the site appears.

    in the template file, try moving this

    wp_reset_postdata();

    into it’s own

    <?php wp_reset_postdata(); ?>`

    i don’t think having them both in the same php brackets is correct php…

    put

    <?php get_header(); ?>

    underneath

    <?php
    /*
    Template Name: All posts
    */
    ?>

    try not leaving a space between the the get_posts('')

    and see what happens. other than that i’m out of ideas. i’ll be away from my laptop all day today, hopefully someone else can make a few suggestions…

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘All Posts stopped working after WP 3.4 upgrade’ is closed to new replies.