The Future Is Now! plugin: nav between future and past blocked in single-post

Home Forums Plugin Integration The Future Is Now! plugin: nav between future and past blocked in single-post

This topic is: not resolved

This topic contains 4 replies, has 2 voices, and was last updated by  middlesister 4 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3379

    nimmolo
    Participant

    Hi gang,

    I think I’ve determined this is a Thematic-specific issue, or at least i can only get it to crop up in Thematic.

    The Future is Now! plugin is a pretty widely used filter (written by Andrew Nacin and Rob Boren) to rewrite future-scheduled posts to the database as ‘published’ so they appear in your blog as normal posts. It basically eliminates “future” as a post-status.

    The plugin is very simple, here is the full code:

    
    remove_action(‘future_post’, ‘_future_post_hook’);
    
    add_filter( ‘wp_insert_post_data’, ‘futurenow_do_not_set_posts_to_future’ );
    
    function futurenow_do_not_set_posts_to_future( $data ) {
     if ( $data[‘post_status’] == ‘future’ && $data[‘post_type’] == ‘post’ )
     $data[‘post_status’] = ‘publish’;
     return $data;
    }
    ?>
    

    So here’s my problem, I can’t fathom why Thematic would be handling the query for nav-previous and nav-next any differently from any other theme, but it appears to:

    In the index loop, we see all posts as expected with the plugin. Past and future posts, in sequential order.

    However, in single post view, one cannot navigate between past and future posts – only within each group.

    To be more specific – in single-post view, if I’m viewing the first future post, WP page nav query does not return a link for a “previous post”, there’s only a link for the “next post” in the future, although there are plenty of past posts. Similarly: If I’m viewing the most recent past post, WP does not return a link for a “next post” in page nav even when there are future posts.

    When I switch themes, these links appear.

    I’m on the latest 2.0 The Future Is Now version- and the latest Thematic 1.0.4.

    Here’s a page for reference. legalaidmarin.org/news

    #3382

    middlesister
    Keymaster

    I  don’t have time right now to do some serious digging, but I can hopefully point you in the right direction.

    Thematic’s post navigation is handled by thematic_previous_post_link() and thematic_next_post_link() in content-extensions.php. It uses the wordpress standard previous_post_link() and next_post_link() functions with the addition of a filter for the arguments. The filters are called thematic_previous_post_link_args and thematic_next_post_link_args, respectively. All thematic does is specify the formatting of the link, it keeps the default args of

    			'in_same_cat' => FALSE,
    			'excluded_categories' => ''

    unchanged. I don’t think the problem lies there.

    A quick look through the code shows that the single post loop does not actually use the loop structure. My guess is that you need the call to the_post() for the future post data to be setup properly. Try

    function childtheme_override_single_post() {
    
    	while ( have_posts() ) : the_post();
    
    		// action hook for insterting content above #post
    		thematic_abovepost();
    		?>
    
    		<div id="post-<?php the_ID(); ?>&#8221; <?php post_class(); ?> >
    
    		<?php
    		// creating the post header
    	        thematic_postheader();
    		?>
    
    		<div class="entry-content">
    
    		<?php thematic_content(); ?>
    
    		<?php wp_link_pages(array('before' => sprintf(&#8216;<div class="page-link">%s&#8217;, __(&#8216;Pages:&#8217;, &#8216;thematic&#8217;)),&#8217;after&#8217; => &#8216;</div>&#8216;)); ?>
    
    		</div><!-- .entry-content -->
    
    		<?php thematic_postfooter(); ?>
    
    		</div><!-- #post -->
    		<?php
    		// action hook for insterting content below #post
    		thematic_belowpost();
    	endwhile;
    
    }

    This is just a hunch. I am going away for two weeks starting tomorrow. If not somebody else chimes in to help you or you manage to solve the problem yourself in the meantime, I'll be happy to help you when I get back.

    #3383

    nimmolo
    Participant

    Thanks Middlesister!    I suspected these areas too, but I couldn’t find anything unusual in the way thematic builds these links either.

    I’m using a childtheme template for single.php, because I needed to rewrite the loop for that. I believe I am calling <code>the_post()</code> correctly in this template, but it’s possible i’m not.

    Here is the single.php template in its entirety so you or others can look over it. I know the relevant part is only the second half, but maybe this will elucidate some things…

    Have a good trip, and thanks for checking it out.

    
    <?php
    /**
     * Single Post Template
     *
     * …
     *
     * @package Thematic
     * @subpackage Templates
     */
    function nim_add_summary() {
    
    global $meta_boxes;
    
     if ( function_exists( 'rwmb_meta' ) ) {
    
    $description = rwmb_meta( 'postsummary_description' );
    
    if ( ! empty($description) ) {
     $summary = '<div class="post-summary">&#8216; . $description . &#8216;</div>&#8216;;
     }
    
    echo $summary;
    
    }
    
    }
    
    function nim_post_thumbnail_with_caption() {
     global $post;
    
    $thumb_id = get_post_thumbnail_id($post->ID);
    
    $args = array(
     &#8216;post_type&#8217; => &#8216;attachment&#8217;,
     &#8216;post_status&#8217; => null,
     &#8216;post_parent&#8217; => $post->ID,
     &#8216;include&#8217; => $thumb_id
     );
    
    $thumbnail_image = get_posts($args);
    
    if ($thumbnail_image &#038;&#038; isset($thumbnail_image[0])) {
    
     $caption = $thumbnail_image[0]->post_excerpt;
    
     }
    
     ?>
     <figure class="postPoster">
     <?php the_post_thumbnail('medium', array('class' => &#8221;)); ?>
     <figcaption class="wp-caption-text">
     <?php echo $caption; ?>
     </figcaption>
     </figure>
     <?php
    
    }
    
    
    /**
     * The Single post loop
     *
     * Located in single.php
     *
     */
    
    function nim_single_post() {
    
    // action hook for insterting content above #post
     thematic_abovepost();
     ?>
    
     <div id="post-<?php the_ID(); ?>&#8221; <?php post_class(); ?> >
    
    <?php
    
    // creating the post header
     thematic_postheader();
     ?>
    
     <div class="entry-content">
    
    <?php nim_post_thumbnail_with_caption();
    
     nim_add_summary();
    
     thematic_content();
    
     wp_link_pages(array('before' => sprintf(&#8216;<div class="page-link">%s&#8217;, __(&#8216;Pages:&#8217;, &#8216;thematic&#8217;)),
     &#8216;after&#8217; => &#8216;</div>&#8216;)); ?>
    
     </div><!-- .entry-content -->
    
     <?php thematic_postfooter(); ?>
    
     </div><!-- #post -->
     <?php
     // action hook for insterting content below #post
     thematic_belowpost();
    
    } // end nim_single_post
    
    
     // calling the header.php
     get_header();
    
    // action hook for placing content above #container
     thematic_abovecontainer();
    ?>
    
    <div id="container">
    
     <?php
     // action hook for placing content above #content
     thematic_abovecontent();
    
     // filter for manipulating the element that wraps the content
     echo apply_filters( 'thematic_open_id_content', '<div id="content">&#8216; . &#8220;\n\n&#8221; );
    
     // start the loop
     while ( have_posts() ) : the_post();
    
     // create the navigation above the content
     thematic_navigation_above();
    
     // calling the widget area &#8216;single-top&#8217;
     get_sidebar(&#8216;single-top&#8217;);
    
     // action hook creating the single post
     nim_single_post();
    
     // calling the widget area &#8216;single-insert&#8217;
     get_sidebar(&#8216;single-insert&#8217;);
    
     // create the navigation below the content
     thematic_navigation_below();
    
     // action hook for calling the comments_template
     thematic_comments_template();
    
     // end the loop
     endwhile;
    
     // calling the widget area &#8216;single-bottom&#8217;
     get_sidebar(&#8216;single-bottom&#8217;);
     ?>
    
     </div><!-- #content -->
    
     <?php
     // action hook for placing content below #content
     thematic_belowcontent();
     ?>
     </div><!-- #container -->
    
    <?php
     // action hook for placing content below #container
     thematic_belowcontainer();
    
    // calling the standard sidebar
     thematic_sidebar();
    
     // calling footer.php
     get_footer();
    ?>
    <div id="post-<?php the_ID(); ?>&#8220;>
    
    #3384

    nimmolo
    Participant

    The plot thickens!

    I’ve been working on implementing WPML for this site, and the navigation works when viewing single posts in Spanish, the site’s second language.

    But the problem still persists in English. ?:|

    #3503

    middlesister
    Keymaster

    Hi nimmolo! I know it has been a while, but did you find a solution for the problem?

    For the record, you don’t need to replicate the whole single.php for rewriting the loop. Delete the child theme’s single.php and put this in your functions.php instead:

    /**
    * Summary from post meta box
    */
    function nim_add_summary() {
    global $meta_boxes;
    
    if ( function_exists( &#8216;rwmb_meta&#8217; ) ) {
    
    $description = rwmb_meta( &#8216;postsummary_description&#8217; );
    
    if ( ! empty($description) ) { $summary = &#8216;<div class="post-summary">&#8216; . $description . &#8216;</div>&#8216;; }
    
    echo $summary;
    
    }
    }
    
    /**
    * Add captioned post thumbnail
    */
    function nim_post_thumbnail_with_caption() {
    global $post;
    
    $thumb_id = get_post_thumbnail_id($post->ID);
    
    $args = array( &#8216;post_type&#8217; => &#8216;attachment&#8217;, &#8216;post_status&#8217; => null, &#8216;post_parent&#8217; => $post->ID, &#8216;include&#8217; => $thumb_id );
    
    $thumbnail_image = get_posts($args);
    
    if ($thumbnail_image &#038;&#038; isset($thumbnail_image[0])) {
    
    $caption = $thumbnail_image[0]->post_excerpt;
    
    }
    
    ?> <figure class="postPoster"> <?php the_post_thumbnail('medium', array('class' => &#8221;)); ?> <figcaption
    class="wp-caption-text"> <?php echo $caption; ?> </figcaption> </figure> <?php
    
    }
    
    
    
    
    /**
    * Replace the single post loop with added summary and post thumnail
    */
    function childtheme_override_single_post() {
    
    while ( have_posts() ) : the_post();
    
    // action hook for insterting content above #post
    thematic_abovepost();
    ?>
    
    <div id="post-<?php the_ID(); ?>&#8221; <?php post_class(); ?> >
    
    <?php
    // creating the post header
    thematic_postheader();
    ?>
    
    <div class="entry-content">
    
    <?php nim_post_thumbnail_with_caption();
    
    nim_add_summary();
    
    thematic_content(); ?>
    
    <?php wp_link_pages(array('before' => sprintf(&#8216;<div class="page-link">%s&#8217;, __(&#8216;Pages:&#8217;, &#8216;thematic&#8217;)),&#8217;after&#8217; => &#8216;</div>&#8216;)); ?>
    
    </div><!-- .entry-content -->
    
    <?php thematic_postfooter(); ?>
    
    </div><!-- #post -->
    <?php
    // action hook for insterting content below #post
    thematic_belowpost();
    endwhile;
    
    }

    I noticed that in your single.php file, the calls to thematic_navigation_above and below are *inside* the while:have_posts loop instead of outside. Perhaps that could be the reason?

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘The Future Is Now! plugin: nav between future and past blocked in single-post’ is closed to new replies.