• Resolved puffinld

    (@puffinld)


    I have some posts with a status of publish and publish date in the future. These are controlled by page templates.

    I have one page where I want to display one post with a future publish date and then other posts in the past but controlled by List Category Posts plugin.

    This was working perfectly before changing from version 3.2 to 34.8.1

    NOW, under 3.8.1, the List Category Posts plugin ONLY shows posts with a future publish date. Website https://www.birminghamchoralunion.org.uk/wordpress/

    Code in the relevant page template is:

    <?php
    /**
    * Template Name: next_concert_home
    */

    get_header(); ?>

    <?php
    /* Run the loop to output the pages.
    * If you want to overload this in a child theme then include a file
    * called loop-page.php and that will be used instead.
    */

    /* Check if the user selects specific category for the templated page */
    $cats = ‘concerts’; // Change these category SLUGS to suit your use.

    // Display the posts from the category with a post_date in the future

    $args= array(
    ‘category_name’ => $cats
    );

    // The Query
    // $the_query = new WP_Query( $args );

    function filter_where($where = ”) {
    $where .= ” AND post_date >= ‘” . date(‘Y-m-d’) . “‘”;
    return $where;
    }
    add_filter(‘posts_where’, ‘filter_where’);

    $my_query = new WP_Query(‘category_name=concerts&order=ASC&posts_per_page=1’);

    // The Loop
    // while ( $the_query->have_posts() ) : $the_query->the_post();
    while ($my_query->have_posts()) : $my_query->the_post();

    // echo ‘

    • ‘;
    • // the_title();
      // the_content();

      get_template_part( ‘loop’, ‘index’ );

      // echo ‘
      ‘;

      endwhile;

      the_post();
      get_template_part( ‘loop’, ‘page’ );

      // Reset Post Data
      wp_reset_postdata();

      ?>

      <?php get_footer(); ?>

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter puffinld

    (@puffinld)

    Has

    wp_reset_postdata();

    been changed?

    I thought that reset all previous options?

    you might need to remove this filter add_filter('posts_where', 'filter_where'); before you call the normal post/page.

    have you checked the ‘List Category Posts’ plugin if the latest revisions have changed the way the category posts are called?

    Thread Starter puffinld

    (@puffinld)

    Thank you
    I have been trying to remove that filter for a day or two but don’t know php well enough to do so. Everything I try results in a completely blank page – no header, just nothing so I can’t be doing it correctly! Any further help would be very gratefully accepted!

    “List Category Posts” ia compatible with 3.8.1. However, for the particular category of “concerts” I prefer to use a page template rather than List Category Posts as that will display attached images. To enable this, I also use the plugin “No Future Posts” which changes the Future status to Publish.

    Thread Starter puffinld

    (@puffinld)

    Why has this changed in 3.8.1 ?

    wp_reset_postdata();

    It all used to work perfectly/

    Thread Starter puffinld

    (@puffinld)

    you might need to remove this filter add_filter(‘posts_where’, ‘filter_where’); before you call the normal post/page.

    Is this done in a second loop?

    Thread Starter puffinld

    (@puffinld)

    After taking well over 2 days trying various things, I now find it is a simple as

    remove_filter(‘posts_where’, ‘filter_where’);

    Thread Starter puffinld

    (@puffinld)

    After at least a couple of days trying various options, I now find that it is a simple as:

    remove_filter(‘posts_where’, ‘filter_where’);

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Page Template different results after 3.8.1’ is closed to new replies.