Custom template for fake posts
-
Hi,
I’ve been going through and refactoring our code after updating the plugin from 1.4.4 to 2.0.1. I noticed that
amp_prepare_render()
has been deprecated.I was previously doing something like this:
add_action( 'wp', function() { $query_var = get_query_var( REWRITE_FLAG ); if ( empty( $query_var ) || !in_array( $query_var, [ 'video-single', 'another-example' ], true ) ) return; global $wp_query; $wp_query->queried_object = new WP_Post( new StdClass() ); amp_prepare_render(); }, 10 ); add_filter( 'amp_post_template_file', function( $template_path, $template_type, $post ) { $query_var = get_query_var( REWRITE_FLAG ); if ( 'video-single' === $query_var ) { $template_path = __DIR__ . '/templates/video.php'; } else if ( 'another-example' === $query_var ) { $template_path = __DIR__ . '/templates/example.php'; } return $template_path; }, 10, 3 );
For a bit more context video is not a real post type. We are generating single detail pages for each video(from a feed) with a rewrite rule.
In the older version I think amp was only working when
is_singular == true
and it had to be a WP_Post so I faked it to bypass it. Is something like this still possible? What can I use in place ofamp_prepare_render()
?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Custom template for fake posts’ is closed to new replies.