Ignore Plugin on Certain Post Type
-
The plugin is working great when i pass ?amp into pages. However, I’d like to have the plugin completely ignored and run custom amp code on certain post types. I’ve tried, but it just returns a 404.
add_filter( 'amp_skip_post', 'isa_skip_posts', 10, 3 ); function isa_skip_posts( $skip, $post_id, $post ) { if (get_post_type() == "summary" ) { $skip = true; } return $skip; }
I want to run the following code to call a separate template to render for a post type, but the ampforwp plugin is loading and rendering a 404 page (the 404 loads in the ampforwp amp design). Ideally, just want the plugin to not run so my code below can execute.
add_filter( 'template_include', 'amp_page_template', 99 ); function amp_page_template( $template ) { $the_slug = str_replace("?amp", "", $_SERVER["REQUEST_URI"]); $args = array( 'name' => $the_slug, 'numberposts' => 1, 'post_type' => 'any' ); $my_posts = get_posts($args); if( $my_posts ) : global $post; $post = $my_posts[0]; setup_postdata( $post); if (strpos($_SERVER['REQUEST_URI'],'?amp') !== false) { if (get_post_type() == "summary" ) { $template = get_template_directory() . '/template-parts/amp/amp-master.php'; } } endif; wp_reset_postdata(); return $template; }
Any help would be greatly appreciated.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Ignore Plugin on Certain Post Type’ is closed to new replies.