Chả là em đang tập tành làm web truyện theo hướng dẫn này
nhưng khi chèn code ở PHP Snippets Dropdown khi lưu thì nó báo lỗi như hình ạ, không biết fix dòng 4 đó kiểu gì luôn? mọi người giúp em với
Mã:
function get_dropdown_part( $id ) {
global $post, $wpdb;
$query = $wpdb->get_results(sprintf('select * from %s where post_type = \'%s\' and post_parent = %d and post_status = \'%s\' order by post_date asc', $wpdb->posts, 'story', $id, 'publish'));
if ($query) {
echo '<form id="selectpart" class="story__form">
<select name="part" onchange="window.location.href = (this.options[this.selectedIndex].value)">
<option value="">- Chọn tập -</option>'; foreach ( $query as $k ) { $uri = get_permalink($k->ID); if ( ! preg_match('/.*page-[0-9].*/', $uri)) echo '<option value="'.$uri.'">'.$k->post_title .'</option>'; } echo '</select></form>';
}
}