You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP Notice: Trying to get property of non-object in /var/www/public/defiant-bat/wp-content/plugins/accelerated-mobile-pages/accelerated-moblie-pages.php on line 39
Source: // Frontpage and Blog page check from reading settings. function ampforwp_name_blog_page() { $page_for_posts = get_option( 'page_for_posts' ); $post = get_post($page_for_posts); $slug = $post->post_name; return $slug; } function ampforwp_custom_post_page() { $front_page_type = get_option( 'show_on_front' ); return $front_page_type; }
and // For Homepage with Pagination if ( ampforwp_custom_post_page() && ampforwp_name_blog_page() ) { add_rewrite_rule( ampforwp_name_blog_page(). '/amp/page/([0-9]{1,})/?$', 'index.php?amp&paged=$matches[1]', 'top' ); }
Else ...page_for_posts return 0, well get_post() not return valid post object ...and push notice on trying read slug.
Try something like: // Blog page check from reading settings. function ampforwp_name_blog_page() { $page_for_posts = get_option( 'page_for_posts' ); if( ampforwp_custom_post_page() == 'page' && $page_for_posts != 0 ) { $post = get_post($page_for_posts); $slug = $post->post_name; return $slug; } return false; } function ampforwp_custom_post_page() { $front_page_type = get_option( 'show_on_front' ); return $front_page_type; }
and // For Blog page with Pagination if ( ampforwp_name_blog_page() ) { add_rewrite_rule( ampforwp_name_blog_page(). '/amp/page/([0-9]{1,})/?$', 'index.php?amp&paged=$matches[1]', 'top' ); }
[12-May-2017 19:40:45 UTC] PHP Notice: Undefined variable: post_id in /var/www/public/defiant-bat/wp-content/plugins/accelerated-mobile-pages/templates/design-manager/design-2/style.php on line 10
style.php in all designs contain: $get_customizer = new AMP_Post_Template( $post_id );
...and $post_id is from ???
The text was updated successfully, but these errors were encountered:
infokurs
changed the title
Some debug problems (blog page, style.php
Some debug problems (blog page, style.php)
May 13, 2017
infokurs
added a commit
to infokurs/accelerated-mobile-pages
that referenced
this issue
May 13, 2017
Corresponds also to reported debug notice https://wordpress.org/support/topic/debug-0-9-49/
PHP Notice: Trying to get property of non-object in /var/www/public/defiant-bat/wp-content/plugins/accelerated-mobile-pages/accelerated-moblie-pages.php on line 39
Source:
// Frontpage and Blog page check from reading settings. function ampforwp_name_blog_page() { $page_for_posts = get_option( 'page_for_posts' ); $post = get_post($page_for_posts); $slug = $post->post_name; return $slug; } function ampforwp_custom_post_page() { $front_page_type = get_option( 'show_on_front' ); return $front_page_type; }
and
// For Homepage with Pagination if ( ampforwp_custom_post_page() && ampforwp_name_blog_page() ) { add_rewrite_rule( ampforwp_name_blog_page(). '/amp/page/([0-9]{1,})/?$', 'index.php?amp&paged=$matches[1]', 'top' ); }
Is a small logic problem.
Blog page is optional and is used only in one case - Reading Settings, Front page displays >> A static page (select below) + selected Posts page.
reference: https://developer.wordpress.org/reference/functions/is_home/#usage
Else ...page_for_posts return 0, well get_post() not return valid post object ...and push notice on trying read slug.
Try something like:
// Blog page check from reading settings. function ampforwp_name_blog_page() { $page_for_posts = get_option( 'page_for_posts' ); if( ampforwp_custom_post_page() == 'page' && $page_for_posts != 0 ) { $post = get_post($page_for_posts); $slug = $post->post_name; return $slug; } return false; } function ampforwp_custom_post_page() { $front_page_type = get_option( 'show_on_front' ); return $front_page_type; }
and
// For Blog page with Pagination if ( ampforwp_name_blog_page() ) { add_rewrite_rule( ampforwp_name_blog_page(). '/amp/page/([0-9]{1,})/?$', 'index.php?amp&paged=$matches[1]', 'top' ); }
[12-May-2017 19:40:45 UTC] PHP Notice: Undefined variable: post_id in /var/www/public/defiant-bat/wp-content/plugins/accelerated-mobile-pages/templates/design-manager/design-2/style.php on line 10
style.php in all designs contain:
$get_customizer = new AMP_Post_Template( $post_id );
...and $post_id is from ???
The text was updated successfully, but these errors were encountered: