| @@ -101,11 +101,22 @@ | ||
| 101 | 101 | $this->end_controls_section(); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | protected function get_dynamic_post_ID() { |
| 105 | - $latest_cpt = get_posts( "post_type=post&numberposts=1" ); | |
| 105 | + $post_type = 'post'; | |
| 106 | + $type = get_post_meta( get_the_ID(), '_templately_template_type', true ); | |
| 107 | + if($type == 'single') { | |
| 108 | + $post_type = 'post'; | |
| 109 | + } | |
| 110 | + else if($type == 'page_single') { | |
| 111 | + $post_type = 'page'; | |
| 112 | + } | |
| 113 | + else if($type == 'product_single') { | |
| 114 | + $post_type = 'product'; | |
| 115 | + } | |
| 116 | + $latest_cpt = get_posts( "post_type=$post_type&numberposts=1" ); | |
| 106 | 117 | |
| 107 | - return Plugin::$instance->editor->is_edit_mode() || isset( $_GET['preview_id'] ) || isset( $_GET['preview'] ) ? $latest_cpt[0]->ID : get_the_ID(); | |
| 118 | + return Plugin::$instance->editor->is_edit_mode() || isset($_GET['templately_library'], $_GET['preview_id']) ? $latest_cpt[0]->ID : get_the_ID(); | |
| 108 | 119 | } |
| 109 | 120 | |
| 110 | 121 | protected function render() { |
| 111 | 122 | $settings = $this->get_settings_for_display(); |