Support » Plugin: Totally Booked » [Plugin: Totally Booked] Recent posts sidebar not updating on archive page

  • Resolved PeterHl

    (@peterhl)


    Hi Ben,

    I am enjoying your plugin and it seems to work all right, but I have an issue I recently noticed:

    I’m using the theme’s (Iconic One Pro) “Recent Posts” widget in the sidebar and the book archive does not seem to be updating this. It’s correct on all the other pages.
    Are you using any kind of caching for the books archiv? Any other ideas?

    allowyourbest.com/books

    Thanks, Peter

    https://wordpress.org/plugins/totally-booked/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Has anyone had a chance to look at this issue?
    Any help would be appreciated…thanks!

    Peter

    Plugin Author Ben Casey

    (@casben79)

    Hi Peter, This is a strange one, I had a look at my plugin and I have an idea, but i’m not 100% it will work.

    in the function pre_get_posts in totally_booked.php (line 280) can you add the following line and let me know if it works? If it does ill push an update immediately.

    if( ! is_main_query() ) return;

    The whole function should look like this when you are done:

    public function pre_get_posts( $query ){
    
            if( ! is_main_query() ) return;
    
            /**
             * Add Support for simple page ordering.
             */
            if( class_exists( 'Simple_Page_Ordering' ) ){
                if( is_post_type_archive( 'tb_book' ) || is_tax( 'tb_genre' ) || is_tax( 'tb_series' ) || is_tax( 'tb_author' ) ){
                    $query->set( 'orderby' , 'menu_order' );
                    $query->set( 'order'   , 'ASC' );
                }
            }
    
            /**
             * Initialise the max posts option
             */
            $maxposts = get_option( 'tb_archive_posts_per_page' );
            if( $maxposts && $maxposts > 0 ){
    
                if( is_post_type_archive( 'tb_book' ) || is_tax( array( 'tb_genre', 'tb_series', 'tb_author' ) ) ){
                    $query->set( 'posts_per_page', (int)$maxposts );
                }
    
            }
    
        }

    Cheers
    Ben

    Hi Ben, sorry for the late response. I tried this, it did not change anything. Remember that I am using a modified book archive template as the original version did not display the sidebar, Here is the code:

    <?php
    /**
     * Totally Booked Archive Template
     *
     * @version 0.1
     * @package totally-booked
     * @since 0.1
     */
    get_header(); ?>
      <?php do_action( 'tb_wrapper_start' ); ?>
            <header class="archive-header">
                <h1 class="archive-title"><?php tb_archive_title() ?></h1>
            </header><!-- .archive-header -->
    
            <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
    
                tb_get_template_part( 'loops/archive' );
    
            endwhile; endif; ?>
    
        <?php do_action( 'tb_wrapper_end' ); ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thanks for your help. Happy Holidays and best wishes for a prosperous New Year!
    Peter
    http://allowyourbest.com

    Plugin Author Ben Casey

    (@casben79)

    Peter, I had made a mistake with the code I gave you, it should be as follows:

    if( ! $query->is_main_query() ) return;

    Try that.

    Having a custom archive shouldn’t be the issue.

    Cheers
    Ben

    Hi Ben, this worked, problem solved!

    Thank you.
    Peter

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Totally Booked] Recent posts sidebar not updating on archive page’ is closed to new replies.