| @@ -261,11 +261,22 @@ | ||
| 261 | 261 | $this->end_controls_section(); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | protected function get_dynamic_post_ID() { |
| 265 | - $latest_cpt = get_posts( "post_type=post&numberposts=1" ); | |
| 265 | + $post_type = 'post'; | |
| 266 | + $type = get_post_meta( get_the_ID(), '_templately_template_type', true ); | |
| 267 | + if($type == 'single') { | |
| 268 | + $post_type = 'post'; | |
| 269 | + } | |
| 270 | + else if($type == 'page_single') { | |
| 271 | + $post_type = 'page'; | |
| 272 | + } | |
| 273 | + else if($type == 'product_single') { | |
| 274 | + $post_type = 'product'; | |
| 275 | + } | |
| 276 | + $latest_cpt = get_posts( "post_type=$post_type&numberposts=1" ); | |
| 266 | 277 | |
| 267 | - return Plugin::$instance->editor->is_edit_mode() || isset( $_GET['preview_id'] ) || isset( $_GET['preview'] ) ? $latest_cpt[0]->ID : get_the_ID(); | |
| 278 | + return Plugin::$instance->editor->is_edit_mode() || isset($_GET['templately_library'], $_GET['preview_id']) ? $latest_cpt[0]->ID : get_the_ID(); | |
| 268 | 279 | } |
| 269 | 280 | |
| 270 | 281 | protected function render() { |
| 271 | 282 | $settings = $this->get_settings_for_display(); |