WordPress.org

Ready to get started?Download WordPress

Forums

All Posts stopped working after WP 3.4 upgrade (10 posts)

  1. andreleibovici
    Member
    Posted 1 year ago #

    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; ?>
  2. Steven Jones
    Member
    Posted 1 year ago #

    When you say stop working do you mean they're not showing up, or do you mean the page isn't loading anymore?

  3. theotherlebowski
    Member
    Posted 1 year ago #

    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!)

  4. andreleibovici
    Member
    Posted 1 year ago #

    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; ?>
  5. theotherlebowski
    Member
    Posted 1 year ago #

    try putting this

    <?php endwhile; ?>

    above

    <?php get_footer(); ?>

  6. andreleibovici
    Member
    Posted 1 year ago #

    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(); ?>
  7. theotherlebowski
    Member
    Posted 1 year ago #

    did you deactivate all your plugins prior to upgrading?

  8. andreleibovici
    Member
    Posted 1 year ago #

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

  9. andreleibovici
    Member
    Posted 1 year ago #

    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; ?>
  10. theotherlebowski
    Member
    Posted 1 year ago #

    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...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.