Undefined variable $q + attempt to read property “max_num_pages” in design-1
-
Hi there,
the following warnings are present in logs after updating to php8.1.
PHP Warning: Undefined variable $q in .../accelerated-mobile-pages/templates/design-manager/design-1/archive.php on line 156 PHP Warning: Attempt to read property "max_num_pages" on null in .../accelerated-mobile-pages/templates/design-manager/design-1/archive.php on line 156
Here is a quick fix to check whether $q was set prior to access its properties.
--- archive.org.php 2022-10-11 09:41:26.222042154 +0200 +++ archive.php 2022-10-11 09:43:00.087727714 +0200 @@ -153,7 +153,7 @@ <div class="amp-wp-content pagination-holder"> <div id="pagination"> - <?php if ( get_next_posts_link('next', $q->max_num_pages) ){ ?><div class="next"><?php echo apply_filters('ampforwp_next_posts_link', get_next_posts_link( ampforwp_translation($redux_builder_amp['amp-translator-next-text'], 'Next' ).'»', 0), $paged ) ?></div><?php }?> + <?php if ( isset($q) && get_next_posts_link('next', $q->max_num_pages) ){ ?><div class="next"><?php echo apply_filters('ampforwp_next_posts_link', get_next_posts_link( ampforwp_translation($redux_builder_amp['amp-translator-next-text'], 'Next' ).'»', 0), $paged ) ?></div><?php }?> <?php if ( get_previous_posts_link() ){ ?><div class="prev"><?php echo apply_filters( 'ampforwp_previous_posts_link', get_previous_posts_link( '« '. ampforwp_translation($redux_builder_amp['amp-translator-previous-text'], 'Previous' )), $paged ); ?></div><?php }?> <div class="clearfix"></div> </div>
Cheers!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Undefined variable $q + attempt to read property “max_num_pages” in design-1’ is closed to new replies.