1136 lines
41 KiB
PHP
1136 lines
41 KiB
PHP
<?php
|
|
|
|
/**
|
|
@ Thiết lập các hằng dữ liệu quan trọng
|
|
@ THEME_URL = get_stylesheet_directory() - đường dẫn tới thư mục theme
|
|
@ CORE = thư mục /core của theme, chứa các file nguồn quan trọng.
|
|
**/
|
|
define( 'THEME_URL', get_stylesheet_directory() );
|
|
define( 'CORE', THEME_URL . '/core' );
|
|
|
|
/**
|
|
@ Load file /core/init.php
|
|
@ Đây là file cấu hình ban đầu của theme mà sẽ không nên được thay đổi sau này.
|
|
**/
|
|
|
|
require_once( CORE . '/init.php' );
|
|
require_once( CORE . '/vnpt.php' );
|
|
require_once( CORE . '/crmhis.php' );
|
|
add_action('init', 'myStartSession', 1);
|
|
function myStartSession() {
|
|
if(!session_id()) {
|
|
session_start();
|
|
}
|
|
}
|
|
/**
|
|
@ Thiết lập $content_width để khai báo kích thước chiều rộng của nội dung
|
|
**/
|
|
if ( ! isset( $content_width ) ) {
|
|
/*
|
|
* Nếu biến $content_width chưa có dữ liệu thì gán giá trị cho nó
|
|
*/
|
|
$content_width = 620;
|
|
}
|
|
|
|
/**
|
|
@ Thiết lập các chức năng sẽ được theme hỗ trợ
|
|
**/
|
|
if ( ! function_exists( 'thanhgiang_theme_setup' ) ) {
|
|
/*
|
|
* Nếu chưa có hàm thanhgiang_theme_setup() thì sẽ tạo mới hàm đó
|
|
*/
|
|
function thanhgiang_theme_setup() {
|
|
/*
|
|
* Thiết lập theme có thể dịch được
|
|
*/
|
|
$language_folder = THEME_URL . '/languages';
|
|
load_theme_textdomain( 'thanhgiang', $language_folder );
|
|
add_theme_support('html5', array('search-form'));
|
|
|
|
/*
|
|
* Tự chèn RSS Feed links trong <head>
|
|
*/
|
|
add_theme_support( 'automatic-feed-links' );
|
|
|
|
/*
|
|
* Thêm chức năng post thumbnail
|
|
*/
|
|
add_theme_support( 'post-thumbnails' );
|
|
|
|
/*
|
|
* Thêm chức năng title-tag để tự thêm <title>
|
|
*/
|
|
add_theme_support( 'title-tag' );
|
|
|
|
/*
|
|
* Thêm chức năng post format
|
|
*/
|
|
add_theme_support( 'post-formats',
|
|
array(
|
|
'video',
|
|
'image',
|
|
'audio',
|
|
'gallery',
|
|
'quote',
|
|
'link'
|
|
)
|
|
);
|
|
|
|
/*
|
|
* Thêm chức năng custom background
|
|
*/
|
|
$default_background = array(
|
|
'default-color' => '#ffffff',
|
|
);
|
|
add_theme_support( 'custom-background', $default_background );
|
|
|
|
/*
|
|
* Tạo menu cho theme
|
|
*/
|
|
register_nav_menu ( 'primary-menu', __('Primary Menu', 'thanhgiang') );
|
|
register_nav_menu ( 'about-menu', __('About Menu', 'thanhgiang') );
|
|
register_nav_menu ( 'edu-menu', __('Education Menu', 'thanhgiang') );
|
|
register_nav_menu ( 'contact-menu', __('Contact Menu', 'thanhgiang') );
|
|
register_nav_menu ( 'footer-01-menu', __('Footer 01 Menu', 'thanhgiang') );
|
|
register_nav_menu ( 'footer-02-menu', __('Footer 02 Menu', 'thanhgiang') );
|
|
register_nav_menu ( 'footer-03-menu', __('Footer 03 Menu', 'thanhgiang') );
|
|
|
|
/*
|
|
* Tạo sidebar cho theme
|
|
*/
|
|
$sidebar = array(
|
|
'name' => __('Main Sidebar', 'thanhgiang'),
|
|
'id' => 'main-sidebar',
|
|
'description' => 'Main sidebar for thanhgiang theme',
|
|
'before_widget' => '',
|
|
'after_widget' => '',
|
|
'class' => 'main-sidebar',
|
|
'before_title' => '<h3 class="widgettitle title-3">',
|
|
'after_title' => '</h3>'
|
|
);
|
|
register_sidebar( $sidebar );
|
|
}
|
|
add_action ( 'init', 'thanhgiang_theme_setup' );
|
|
|
|
}
|
|
|
|
function my_function_admin_bar() {
|
|
return false;
|
|
}
|
|
add_filter('show_admin_bar', 'my_function_admin_bar');
|
|
|
|
function create_custom_post_type()
|
|
{
|
|
$label = array(
|
|
'name' => __('Sliders', 'thanhgiang'),
|
|
'singular_name' => __('Slider', 'thanhgiang'),
|
|
'menu_name' => __('Sliders', 'thanhgiang'),
|
|
'slider' => 'slider'
|
|
);
|
|
$args = array(
|
|
'labels' => $label, //Gọi các label trong biến $label ở trên
|
|
'description' => 'Post type đăng slider', //Mô tả của post type
|
|
'supports' => array(
|
|
'title',
|
|
'custom-fields'
|
|
), //Các tính năng được hỗ trợ trong post type
|
|
'hierarchical' => false, //Cho phép phân cấp, nếu là false thì post type này giống như Post, false thì giống như Page
|
|
'public' => true, //Kích hoạt post type
|
|
'show_ui' => true, //Hiển thị khung quản trị như Post/Page
|
|
'show_in_menu' => true, //Hiển thị trên Admin Menu (tay trái)
|
|
'show_in_nav_menus' => true, //Hiển thị trong Appearance -> Menus
|
|
'show_in_admin_bar' => true, //Hiển thị trên thanh Admin bar màu đen.
|
|
'menu_position' => 5, //Thứ tự vị trí hiển thị trong menu (tay trái)
|
|
'menu_icon' => 'dashicons-images-alt', //Đường dẫn tới icon sẽ hiển thị
|
|
'can_export' => true, //Có thể export nội dung bằng Tools -> Export
|
|
'has_archive' => true, //Cho phép lưu trữ (month, date, year)
|
|
'exclude_from_search' => true, //Loại bỏ khỏi kết quả tìm kiếm
|
|
'publicly_queryable' => true, //Hiển thị các tham số trong query, phải đặt true
|
|
'capability_type' => 'post' //
|
|
);
|
|
register_post_type('slider', $args);
|
|
}
|
|
add_action('init', 'create_custom_post_type');
|
|
|
|
function create_taxonomy() {
|
|
|
|
/* Biến $label chứa các tham số thiết lập tên hiển thị của Taxonomy
|
|
*/
|
|
$labels = array(
|
|
'name' => __('Slider categories', 'thanhgiang'),
|
|
'singular' => __('Slider category', 'thanhgiang'),
|
|
'menu_name' => __('Slider categories', 'thanhgiang')
|
|
);
|
|
|
|
/* Biến $args khai báo các tham số trong custom taxonomy cần tạo
|
|
*/
|
|
$args = array(
|
|
'labels' => $labels,
|
|
'hierarchical' => true,
|
|
'public' => true,
|
|
'show_ui' => true,
|
|
'show_admin_column' => true,
|
|
'show_in_nav_menus' => true,
|
|
'show_tagcloud' => true,
|
|
);
|
|
|
|
/* Hàm register_taxonomy để khởi tạo taxonomy
|
|
*/
|
|
register_taxonomy('slider-category', array('slider'), $args);
|
|
}
|
|
// Hook into the 'init' action
|
|
add_action( 'init', 'create_taxonomy', 0 );
|
|
|
|
|
|
|
|
/**
|
|
*thanhgiang_gettext()
|
|
*/
|
|
if ( ! function_exists( 'thanhgiang_gettext' ) ) {
|
|
function thanhgiang_gettext($slug) {
|
|
global $tg_options;
|
|
echo __($tg_options[$slug],'thanhgiang'); }
|
|
}
|
|
|
|
if ( ! function_exists( 'thanhgiang_customer_info' ) ) {
|
|
function thanhgiang_customer_info() {
|
|
$id = 0;
|
|
|
|
if(isset($_SESSION['user_id'])){
|
|
$id = $_SESSION['user_id'];
|
|
}
|
|
|
|
$response = wp_remote_get( WP_CRM_API.'/api/portal/clinics/appointment/'.$id);
|
|
if( is_wp_error( $response ) ) {
|
|
return $response; // Bail early
|
|
}
|
|
$response_body = wp_remote_retrieve_body( $response );
|
|
$appointments = json_decode( $response_body );
|
|
$sessions_data = array();
|
|
foreach ($appointments as $key => $appointment) {
|
|
$date = $appointment->bookingTime;
|
|
$sessions_data[] = (object)array(
|
|
"session" => "Phiên khám ngày " . $date,
|
|
"doctor" => "BS ".$appointment->doctor->fullName,
|
|
"date" => $date,
|
|
"code"=> $appointment ->code,
|
|
"id"=> $appointment ->id,
|
|
"prescription" => "#",
|
|
"testResult" => "#");
|
|
}
|
|
$request = wp_remote_get(WP_CRM_API. '/api/portal/accounts/getpatient?id='.$id );
|
|
if( is_wp_error( $request ) ) {
|
|
return false; // Bail early
|
|
}
|
|
$body = wp_remote_retrieve_body( $request );
|
|
$data = json_decode( $body );
|
|
if( ! empty( $data ) ) { ?>
|
|
<div class="tab-content">
|
|
<div id="info" class="tab-pane fade in active container">
|
|
<div class="row">
|
|
<div class="col">
|
|
<img class="cuscomter-pic img-responsive img-thumbnail" src="<?php echo get_template_directory_uri() . '/img/tempt/missing_avatar.svg'; ?>" />
|
|
</div>
|
|
<div class="col">
|
|
<h3><?php echo $data->fullName; ?></h3>
|
|
<ul>
|
|
<li>Mã bệnh nhân: <?php echo $data->code; ?></li>
|
|
<li>Giới tính: <?php echo $data->genderDisplay; ?></li>
|
|
<li>Điện thoại: <?php echo $data->phoneNumber; ?></li>
|
|
<li>Hôn nhân: <?php echo $data->phoneNumber; ?></li>
|
|
<li>Địa chỉ: <?php echo $data->address; ?></li>
|
|
</ul>
|
|
<div class="customer-cmd">
|
|
<a href="#" onclick="changePassword()">Thay đổi mật khẩu</a>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<ul>
|
|
<li>Năm sinh: <?php echo $data->yob; ?></li>
|
|
<li>Email: <?php echo $data->email; ?></li>
|
|
<li>Nghề nghiệp: <?php echo $data->job; ?></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
$s_demo = (object)array("sessions" =>(object)$sessions_data);
|
|
//var_dump($s_demo->sessions);
|
|
thanhgiang_customer_session($s_demo);
|
|
$n_demo = (object)array("notices" => (object)array(
|
|
(object)array(
|
|
"title" => "Thông báo",
|
|
"date" => "23/08/2018 15:06",
|
|
"link" => "#"),
|
|
(object)array(
|
|
"title" => "Thông báo",
|
|
"date" => "23/08/2018 15:06",
|
|
"link" => "#"),
|
|
(object)array(
|
|
"title" => "Thông báo",
|
|
"date" => "23/08/2018 15:06",
|
|
"link" => "#")));
|
|
thanhgiang_customer_notice($n_demo);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'thanhgiang_customer_session' ) ) {
|
|
function thanhgiang_customer_session($data) {?>
|
|
<div id="session" class="tab-pane fade">
|
|
<div class="table-responsive">
|
|
<table class="table">
|
|
<tr>
|
|
<th>STT</th>
|
|
<th>Phiên khám</th>
|
|
<th>Bác sĩ</th>
|
|
<th>Thời gian</th>
|
|
<!-- <th>Toa thuốc</th> -->
|
|
<th>Kết quả</th>
|
|
</tr>
|
|
<?php
|
|
$count = 1;
|
|
foreach($data->sessions as $session) { ?>
|
|
<tr>
|
|
<td><?php echo $count; ?></td>
|
|
<td><?php echo $session->session; ?></td>
|
|
<td><?php echo $session->doctor; ?></td>
|
|
<td><?php echo $session->date; ?></td>
|
|
<!-- <td><a onclick="xemtoathuoc(<?php echo $session->code; ?>)" href="<?php echo esc_url( $session->prescription ); ?>">Xem</a></td> -->
|
|
<td><a onclick="xemkq(<?php echo $session->id; ?>)">Xem KQ</a></td>
|
|
</tr>
|
|
<?php $count++; }
|
|
?>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'thanhgiang_customer_notice' ) ) {
|
|
function thanhgiang_customer_notice($data) {?>
|
|
<div id="notice" class="tab-pane fade">
|
|
<div class="table-responsive">
|
|
<table class="table">
|
|
<tr>
|
|
<th>STT</th>
|
|
<th>Tiêu đề</th>
|
|
<th>Thời gian gửi</th>
|
|
<th></th>
|
|
</tr>
|
|
<?php
|
|
$count = 1;
|
|
foreach($data->notices as $notice) { ?>
|
|
<tr>
|
|
<td><?php echo $count; ?></td>
|
|
<td><?php echo $notice->title; ?></td>
|
|
<td><?php echo $notice->date; ?></td>
|
|
<td><a href="<?php echo esc_url( $notice->link ); ?>">Xem</a></td>
|
|
</tr>
|
|
<?php $count++; }
|
|
?>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
/**
|
|
@ Thiết lập hàm hiển thị logo
|
|
@ thanhgiang_logo()
|
|
**/
|
|
if ( ! function_exists( 'thanhgiang_logo' ) ) {
|
|
function thanhgiang_logo() {?>
|
|
<div class="logo">
|
|
<?php
|
|
global $tg_options;
|
|
$current_language = pll_current_language();
|
|
// Kiểm tra ngôn ngữ và thêm đoạn text tương ứng
|
|
if ($current_language === 'en') {
|
|
$url = 'https://sisvietnam.vn/wp-content/uploads/2024/12/sis-logo_en.png';
|
|
}elseif ($current_language === 'vi') {
|
|
$url = get_template_directory_uri() . '/img/sis-logo.png';
|
|
}
|
|
|
|
if( !empty($tg_options['logo-image']['url'] )):
|
|
$url = $tg_options['logo-image']['url'];
|
|
endif;
|
|
?>
|
|
<a href="<?php echo get_bloginfo( 'url' ); ?>"><img src="<?php echo $url; ?>" alt="SIS logo"/></a>
|
|
</div>
|
|
<?php }
|
|
}
|
|
|
|
if ( ! function_exists( 'thanhgiang_booking_page' ) ) {
|
|
function thanhgiang_booking_page() {
|
|
global $tg_options;
|
|
if( isset($tg_options['booking']))
|
|
echo get_permalink( $tg_options['booking'] );
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'thanhgiang_intro' ) ) {
|
|
function thanhgiang_intro() {
|
|
global $tg_options;
|
|
$intro_03_ico = get_template_directory_uri() . "/img/tempt/ico-service.png";
|
|
if (!empty($tg_options['intro-03-ico']['url'])):
|
|
$intro_03_ico = $tg_options['intro-03-ico']['url'];
|
|
endif;
|
|
if( isset($tg_options['intro-03'])):
|
|
$term_id = pll_get_term($tg_options['intro-03']);
|
|
$cateObj = get_category($term_id);
|
|
$args = array( 'posts_per_page' => 4, 'cat' => $cateObj->term_id );
|
|
$my_posts = new WP_Query( $args );
|
|
if($my_posts->have_posts()): ?>
|
|
<div class="intro-3">
|
|
<div class="container">
|
|
<div class="tb-col break-640">
|
|
<div class="col image">
|
|
<?php
|
|
if(isset($tg_options['intro-03-post'])):
|
|
$post_id = pll_get_post($tg_options['intro-03-post']);
|
|
$postObj = get_post($post_id);
|
|
?>
|
|
<h3><?php echo $postObj->post_title; ?></h3>
|
|
<div>
|
|
<?php echo $postObj->post_content; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="col content">
|
|
<h2><img src="<?php echo $intro_03_ico ?>" alt="" /> <?php echo $cateObj->name ?></h2>
|
|
<ul>
|
|
<?php
|
|
while ( $my_posts->have_posts() ):
|
|
$my_posts->the_post();
|
|
$ico = get_field('icon_post'); ?>
|
|
<li><a href="<?php the_permalink(); ?>"><img src="<?php echo $ico['url'] ?>" alt="" /> <?php strtoupper(the_title()); ?></a></li>
|
|
<?php
|
|
endwhile;
|
|
?></ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div><?php
|
|
wp_reset_postdata();
|
|
endif;
|
|
endif;
|
|
if( isset($tg_options['intro-02'])):
|
|
$term_id = pll_get_term($tg_options['intro-02']);
|
|
$cateObj = get_category($term_id);
|
|
$args = array( 'posts_per_page' => 3, 'cat' => $cateObj->term_id, 'post_status' => 'publish' );
|
|
$my_posts = new WP_Query( $args );
|
|
if($my_posts->have_posts()): ?>
|
|
<div class="intro-2">
|
|
<div class="container">
|
|
<h2 class="title-1 fa fa-plus"><?php echo $cateObj->name ?></h2>
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<?php
|
|
while ( $my_posts->have_posts() ):
|
|
$my_posts->the_post();
|
|
$date = get_the_date('Y-m-d H:i:s');
|
|
?>
|
|
<div class="grid-1 clearfix">
|
|
<figure>
|
|
<a href="#" class="imgeffect">
|
|
<img class="bgimg" src="<?php the_post_thumbnail_url( 'full' ); ?>" alt="" />
|
|
<span class="date"><?php echo date('d', strtotime($date)); ?> <strong><?php echo strtoupper(date('M', strtotime($date))); ?></strong></span>
|
|
</a>
|
|
</figure>
|
|
<div class="content">
|
|
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
|
|
<p><?php the_excerpt(); ?></p>
|
|
<p><a href="<?php the_permalink(); ?>" class="fa fa-arrow-right"><?php _e('Read More', 'thanhgiang') ?></a></p>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endwhile;
|
|
?></div>
|
|
<div class="col-md-4 ads-banner">
|
|
<?php
|
|
$ads01 = get_template_directory_uri() . '/img/ads-banner.jpg';
|
|
if( !empty($tg_options['ads01']['url'] )):
|
|
$ads01 = $tg_options['ads01']['url'];
|
|
endif;?>
|
|
<img src="<?php echo $ads01 ?>" alt=""/>
|
|
<?php
|
|
$ads02 = get_template_directory_uri() . '/img/ads-banner.jpg';
|
|
if( !empty($tg_options['ads02']['url'] )):
|
|
$ads02 = $tg_options['ads02']['url'];
|
|
endif; ?>
|
|
<img src="<?php echo $ads02 ?>" alt=""/>
|
|
<?php
|
|
$ads03 = get_template_directory_uri() . '/img/ads-banner.jpg';
|
|
if( !empty($tg_options['ads03']['url'] )):
|
|
$ads03 = $tg_options['ads03']['url'];
|
|
endif; ?>
|
|
<img src="<?php echo $ads03 ?>" alt=""/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div><?php
|
|
wp_reset_postdata();
|
|
endif;
|
|
endif;
|
|
?>
|
|
<?php
|
|
$intro_01_bg = "https://sisvietnam.vn/wp-content/uploads/2022/10/call_center_v10.png";
|
|
if ($tg_options['intro-01-bg']['url'] != ''):
|
|
$intro_01_bg = $tg_options['intro-01-bg']['url'];
|
|
endif;
|
|
if( isset($tg_options['intro-01']) ):
|
|
$term_id = pll_get_term($tg_options['intro-01']);
|
|
$cateObj = get_category($term_id);
|
|
$args = array( 'posts_per_page' => 2, 'cat' => $cateObj->term_id, 'post_status' => 'publish' );
|
|
$my_posts = new WP_Query( $args );
|
|
if($my_posts->have_posts()): ?>
|
|
<div class="intro-1">
|
|
<div class="container">
|
|
<div class="content">
|
|
<h2 class="title-1 fa fa-plus"><?php echo $cateObj->name; ?></h2>
|
|
<?php while ( $my_posts->have_posts() ):
|
|
$my_posts->the_post();
|
|
$date = get_the_date('Y-m-d H:i:s'); ?>
|
|
<div class="grid-6 clearfix">
|
|
<div class="date-post">
|
|
<strong><?php echo date('d', strtotime($date)); ?></strong> <?php echo strtoupper(date('M', strtotime($date))); ?>
|
|
</div>
|
|
<div class="descript">
|
|
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
|
|
<p><?php the_excerpt(); ?></p>
|
|
<a href="<?php the_permalink(); ?>" class="more fa fa-arrow-right"><?php _e('Detail','thanhgiang'); ?></a>
|
|
</div>
|
|
</div>
|
|
<?php endwhile; endif; ?>
|
|
</div>
|
|
</div>
|
|
<a href="https://sisvietnam.vn/tong-dai-cap-cuu-call-center/">
|
|
<div class="bg">
|
|
<img class="bgimg" src="<?php echo $intro_01_bg; ?>" alt="" />
|
|
<!-- <h3><strong>Tư vấn qua tổng đài</strong> call center</h3>
|
|
<a href="http://demo.dotquy.vn/tong-dai-cap-cuu-call-center" class="btn-1">Xem chi tiết</a> -->
|
|
</div></a>
|
|
</div>
|
|
<?php endif;
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists('thanhgiang_employee') ) {
|
|
function thanhgiang_employee ($department,$taxonomy_name) {
|
|
$args = array( 'post_type' => 'employee',
|
|
'tax_query' => array(
|
|
array(
|
|
'taxonomy' => $taxonomy_name,
|
|
'field' => 'term_id',
|
|
'terms' => $department->term_id,
|
|
'include_children' => false
|
|
),
|
|
),
|
|
'post_status' => 'publish',
|
|
'meta_key' => 'order',
|
|
'orderby' => 'meta_value',
|
|
'order' => 'ASC' );
|
|
$my_posts = new WP_Query( $args );
|
|
if($my_posts->have_posts()):
|
|
while ( $my_posts->have_posts() ):
|
|
$my_posts->the_post();
|
|
$index=get_the_ID();
|
|
?>
|
|
|
|
<div class="grid-7 clearfix">
|
|
<figure>
|
|
<a href="#pp-<?php echo $index?>" data-toggle="modal">
|
|
<img src="<?php echo get_field('image')['url']; ?>" alt="" /></a></figure>
|
|
<div class="descript">
|
|
<p class="name"><a href="#pp-<?php echo $index?>" data-toggle="modal"><?php echo get_field('position'); ?>: <?php the_title(); ?></a></p>
|
|
<p><?php echo the_excerpt() ?></p>
|
|
<div class="more"><a href="#pp-<?php echo $index?>" data-toggle="modal" class="fa fa-arrow-right">Xem chi tiết</a></div>
|
|
</div>
|
|
</div>
|
|
<div id="pp-<?php echo $index?>" class="modal fade bs-example-modal-lg">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
|
|
<div class="grid-7 clearfix">
|
|
<figure> <img src="<?php echo get_field('image')['url']; ?>" alt="" /></figure>
|
|
<div class="descript" style='width:77%'>
|
|
<p class="name"><?php echo get_field('position'); ?>: <?php the_title(); ?></p>
|
|
<p><?php echo the_content()?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endwhile;
|
|
wp_reset_postdata();
|
|
endif;
|
|
}
|
|
}
|
|
|
|
if( !function_exists('thanhgiang_get_about_page')) {
|
|
function thanhgiang_get_about_page() {
|
|
$args = array( 'post_type' => 'page',
|
|
'post_status' => 'publish',
|
|
'meta_key' => '_wp_page_template',
|
|
'meta_value' => 'templates/education.php',
|
|
'order' => 'ASC' );
|
|
$my_posts = new WP_Query( $args ); ?>
|
|
<div class="content">
|
|
<ul>
|
|
<?php
|
|
if($my_posts->have_posts()):
|
|
while ( $my_posts->have_posts() ):
|
|
$my_posts->the_post();
|
|
$index=get_the_ID();
|
|
?>
|
|
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
|
|
<?php
|
|
endwhile;
|
|
wp_reset_postdata();
|
|
endif; ?>
|
|
</ul>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
/**
|
|
@ Thiết lập hàm hiển thị menu
|
|
@ thanhgiang_menu( $slug )
|
|
**/
|
|
if ( ! function_exists( 'thanhgiang_menu' ) ) {
|
|
function thanhgiang_menu( $slug ) {
|
|
$menu = array(
|
|
'theme_location' => $slug,
|
|
'container' => '',
|
|
'items_wrap' => '<ul class="menu">%3$s</ul>',
|
|
);
|
|
wp_nav_menu( $menu );
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'thanhgiang_about_menu' ) ) {
|
|
function thanhgiang_about_menu( $slug ) {
|
|
$menu = array(
|
|
'theme_location' => $slug,
|
|
'container' => 'div',
|
|
'container_class' => 'content',
|
|
'items_wrap' => '<ul>%3$s</ul>',
|
|
);
|
|
wp_nav_menu( $menu );
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'thanhgiang_footer_menu' ) ) {
|
|
function thanhgiang_footer_menu( $slug ) {
|
|
$menu = array(
|
|
'theme_location' => $slug,
|
|
'container' => 'div',
|
|
'container_class' => 'col-xs-4 col',
|
|
'items_wrap' => '<ul class="links">%3$s</ul>',
|
|
);
|
|
wp_nav_menu( $menu );
|
|
}
|
|
}
|
|
|
|
if ( !function_exists('thanhgiang_get_first_image') ) {
|
|
function thanhgiang_get_first_image() {
|
|
global $post, $posts;
|
|
$first_img = '';
|
|
if (has_post_thumbnail( $post )) {
|
|
$first_img = get_the_post_thumbnail_url($post);
|
|
}
|
|
else {
|
|
ob_start();
|
|
ob_end_clean();
|
|
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
|
|
if(isset($matches [1] [0]))
|
|
$first_img = $matches [1] [0];
|
|
|
|
if(empty($first_img)){ //Defines a default image
|
|
//$first_img = get_template_directory_uri() . '/images/default.jpg'; //Duong dan anh mac dinh khi khong tim duoc anh dai dien
|
|
$first_img = get_the_post_thumbnail_url($post);
|
|
}
|
|
if(empty($first_img)){ //Defines a default image
|
|
$first_img = get_template_directory_uri() . '/img/default.jpg'; //Duong dan anh mac dinh khi khong tim duoc anh dai dien
|
|
}
|
|
}
|
|
return $first_img;
|
|
}
|
|
}
|
|
|
|
/**
|
|
@ Hàm hiển thị ảnh thumbnail của post.
|
|
@ Ảnh thumbnail sẽ không được hiển thị trong trang single
|
|
@ Nhưng sẽ hiển thị trong single nếu post đó có format là Image
|
|
@ thanhgiang_thumbnail( $size )
|
|
**/
|
|
if ( ! function_exists( 'thanhgiang_thumbnail' ) ) {
|
|
function thanhgiang_thumbnail( $size ) {
|
|
// Chỉ hiển thumbnail với post không có mật khẩu
|
|
if ( ! is_single() && has_post_thumbnail() && ! post_password_required() || has_post_format( 'image' ) ) : ?>
|
|
<figure><a class="imgwrap" href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail($size); ?>" alt="" /></a></figure><?php
|
|
endif;
|
|
}
|
|
}
|
|
|
|
/**
|
|
@ Hàm hiển thị tiêu đề của post trong .entry-header
|
|
@ Tiêu đề của post sẽ là nằm trong thẻ <h1> ở trang single
|
|
@ Còn ở trang chủ và trang lưu trữ, nó sẽ là thẻ <h2>
|
|
@ thanhgiang_entry_header()
|
|
**/
|
|
if ( ! function_exists( 'thanhgiang_entry_header' ) ) {
|
|
function thanhgiang_entry_header() {
|
|
if ( is_single() ) : ?>
|
|
|
|
<h1 class="entry-title">
|
|
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
|
|
<?php the_title(); ?>
|
|
</a>
|
|
</h1>
|
|
<?php else : ?>
|
|
<h2 class="entry-title">
|
|
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
|
|
<?php the_title(); ?>
|
|
</a>
|
|
</h2><?php
|
|
|
|
endif;
|
|
}
|
|
}
|
|
|
|
/**
|
|
@ Hàm hiển thị thông tin của post (Post Meta)
|
|
@ thanhgiang_entry_meta()
|
|
**/
|
|
if( ! function_exists( 'thanhgiang_entry_meta' ) ) {
|
|
function thanhgiang_entry_meta() {
|
|
if ( ! is_page() ) :
|
|
echo '<p class="type">';
|
|
|
|
// Hiển thị tên tác giả, tên category và ngày tháng đăng bài
|
|
printf( __('Post in %1$s', 'thanhgiang'),
|
|
get_the_category_list( ', ' ) );
|
|
|
|
// printf( __(' Our Blog by <a href="%2$s">%1$s</a>', 'thanhgiang'),
|
|
// get_the_author(), get_the_author_link() );
|
|
|
|
// Hiển thị số đếm lượt bình luận
|
|
// if ( comments_open() ) :
|
|
// echo ' | <a href="#">';
|
|
// comments_popup_link(
|
|
// __('Leave a comment', 'thanhgiang'),
|
|
// __('1 comment', 'thanhgiang'),
|
|
// __('% comments', 'thanhgiang'),
|
|
// __('Read all comments', 'thanhgiang')
|
|
// );
|
|
// echo '</a>';
|
|
// endif;
|
|
echo '</p>';
|
|
endif;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
@ Hàm hiển thị nội dung của post type
|
|
@ Hàm này sẽ hiển thị đoạn rút gọn của post ngoài trang chủ (the_excerpt)
|
|
@ Nhưng nó sẽ hiển thị toàn bộ nội dung của post ở trang single (the_content)
|
|
@ thanhgiang_entry_content()
|
|
**/
|
|
if ( ! function_exists( 'thanhgiang_entry_content' ) ) {
|
|
function thanhgiang_entry_content() {
|
|
|
|
if ( ! is_single() && ! is_page() ) :
|
|
the_excerpt();
|
|
else :
|
|
the_content();
|
|
|
|
/*
|
|
* Code hiển thị phân trang trong post type
|
|
*/
|
|
$link_pages = array(
|
|
'before' => __('<p>Page:', 'thanhgiang'),
|
|
'after' => '</p>',
|
|
'nextpagelink' => __( 'Next page', 'thanhgiang' ),
|
|
'previouspagelink' => __( 'Previous page', 'thanhgiang' )
|
|
);
|
|
wp_link_pages( $link_pages );
|
|
endif;
|
|
|
|
}
|
|
}
|
|
|
|
/**
|
|
@ Hàm hiển thị info ở trang chủ
|
|
**/
|
|
if ( !function_exists( 'thanhgiang_info' ) ){
|
|
function thanhgiang_info( $id ){
|
|
while ( have_posts() ) : the_post();
|
|
if ( get_post($id) ) :
|
|
$page = get_post($id);
|
|
echo $page->post_content;
|
|
endif;
|
|
endwhile;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
@ Hàm hiển thị tag của post
|
|
@ thanhgiang_entry_tag()
|
|
**/
|
|
if ( ! function_exists( 'thanhgiang_entry_tag' ) ) {
|
|
function thanhgiang_entry_tag() {
|
|
if ( has_tag() ) :
|
|
echo '<div class="entry-tag">';
|
|
printf( __('Tagged in %1$s', 'thanhgiang'), get_the_tag_list( '', ', ' ) );
|
|
echo '</div>';
|
|
endif;
|
|
}
|
|
}
|
|
|
|
function thanhgiang_set_post_views($postID) {
|
|
$count_key = 'tg_post_views_count';
|
|
$count = get_post_meta($postID, $count_key, true);
|
|
if($count==''){
|
|
$count = 0;
|
|
delete_post_meta($postID, $count_key);
|
|
add_post_meta($postID, $count_key, '0');
|
|
}else{
|
|
$count++;
|
|
update_post_meta($postID, $count_key, $count);
|
|
}
|
|
}
|
|
//To keep the count accurate, lets get rid of prefetching
|
|
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
|
|
|
|
function thanhgiang_get_post_views($postID){
|
|
$count_key = 'tg_post_views_count';
|
|
$count = get_post_meta($postID, $count_key, true);
|
|
if($count==''){
|
|
delete_post_meta($postID, $count_key);
|
|
add_post_meta($postID, $count_key, '0');
|
|
return "0 View";
|
|
}
|
|
return $count.' Views';
|
|
}
|
|
|
|
function thanhgiang_numeric_posts_nav() {
|
|
|
|
if( is_singular() )
|
|
return;
|
|
|
|
global $wp_query;
|
|
|
|
/** Stop execution if there's only 1 page */
|
|
if( $wp_query->max_num_pages <= 1 )
|
|
return;
|
|
|
|
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
|
|
$max = intval( $wp_query->max_num_pages );
|
|
|
|
/** Add current page to the array */
|
|
if ( $paged >= 1 )
|
|
$links[] = $paged;
|
|
|
|
/** Add the pages around the current page to the array */
|
|
if ( $paged >= 3 ) {
|
|
$links[] = $paged - 1;
|
|
$links[] = $paged - 2;
|
|
}
|
|
|
|
if ( ( $paged + 2 ) <= $max ) {
|
|
$links[] = $paged + 2;
|
|
$links[] = $paged + 1;
|
|
}
|
|
|
|
echo '<div class="pager"><ul>' . "\n";
|
|
|
|
/** Previous Post Link */
|
|
if ( get_previous_posts_link() )
|
|
printf( '<li>%s</li>' . "\n", get_previous_posts_link() );
|
|
|
|
/** Link to first page, plus ellipses if necessary */
|
|
if ( ! in_array( 1, $links ) ) {
|
|
$class = 1 == $paged ? ' class="active"' : '';
|
|
|
|
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
|
|
|
|
if ( ! in_array( 2, $links ) )
|
|
echo '<li>…</li>';
|
|
}
|
|
|
|
/** Link to current page, plus 2 pages in either direction if necessary */
|
|
sort( $links );
|
|
foreach ( (array) $links as $link ) {
|
|
$class = $paged == $link ? ' class="active"' : '';
|
|
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
|
|
}
|
|
|
|
/** Link to last page, plus ellipses if necessary */
|
|
if ( ! in_array( $max, $links ) ) {
|
|
if ( ! in_array( $max - 1, $links ) )
|
|
echo '<li>…</li>' . "\n";
|
|
|
|
$class = $paged == $max ? ' class="active"' : '';
|
|
printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
|
|
}
|
|
|
|
/** Next Post Link */
|
|
if ( get_next_posts_link() )
|
|
printf( '<li>%s</li>' . "\n", get_next_posts_link() );
|
|
|
|
echo '</ul></div>' . "\n";
|
|
|
|
}
|
|
|
|
if( ! function_exists( 'the_paginate' ) ) :
|
|
function the_paginate($args = null) {
|
|
$defaults = array(
|
|
'title' => 'Pages',
|
|
'query' => null
|
|
);
|
|
$args = wp_parse_args($args, $defaults);
|
|
extract($args, EXTR_SKIP);
|
|
if(is_404()) {
|
|
return;
|
|
}
|
|
$currentPage = null;
|
|
$totalPage = null;
|
|
if(empty($query)) {
|
|
global $wp_query;
|
|
$query = $wp_query;
|
|
}
|
|
$currentPage = stheme_get_paged();
|
|
$title .= ':';
|
|
$ppp = intval($query->query_vars['posts_per_page']);
|
|
if($ppp < 1) {
|
|
return;
|
|
}
|
|
$totalPage = intval(ceil($query->found_posts / $ppp));
|
|
if($totalPage <= 1) {
|
|
return;
|
|
}
|
|
$paginateResult = '<div id="sPaginate" class="spaginate paginate"><div class="spaginate-inner paginate-inner"><span class="spaginate-title paginate-title">'.$title.'</span>';
|
|
|
|
if ($currentPage > 1) {
|
|
$paginateResult .= '<a class="spaginate-prev prev page-item" href="'.get_pagenum_link($currentPage - 1).'">«</a>';
|
|
}
|
|
$paginateResult .= the_paginate_list(1, $totalPage, $currentPage);
|
|
if ($currentPage < $totalPage) {
|
|
$paginateResult .= "<a href='" . get_pagenum_link($currentPage + 1) . "' class='spaginate-next next page-item'>»</a>";
|
|
}
|
|
$paginateResult .= "</div></div>";
|
|
echo $paginateResult;
|
|
}
|
|
endif;
|
|
|
|
if( ! function_exists( 'stheme_paginate' ) ) :
|
|
function stheme_paginate($args = null) {
|
|
the_paginate($args);
|
|
}
|
|
endif;
|
|
|
|
if( ! function_exists( 'the_paginate_list' ) ) :
|
|
function the_paginate_list($intStart, $totalPage, $currentPage) {
|
|
$pageHidden = '<span class="spaginate-hidden hidden">...</span>';
|
|
$linkResult = "";
|
|
$hiddenBefore = false;
|
|
$hiddenAfter = false;
|
|
for ($i = $intStart; $i <= $totalPage; $i++) {
|
|
if($currentPage === intval($i)) {
|
|
$linkResult .= '<span class="spaginate-current page-item current">'.$i.'</span>';
|
|
}
|
|
else if(($i <= 6 && $currentPage < 10) || $i == $totalPage || $i == 1 || $i < 4 || ($i <= 6 && $totalPage <= 6) || ($i > $currentPage && ($i <= ($currentPage + 2))) || ($i < $currentPage && ($i >= ($currentPage - 2))) || ($i >= ($totalPage - 2) && $i < $totalPage)) {
|
|
$linkResult .= '<a class="spaginate-link page-item" href="'.get_pagenum_link($i).'">'.$i.'</a>';
|
|
if($i <= 6 && $currentPage < 10) {
|
|
$hiddenBefore = true;
|
|
}
|
|
}
|
|
else {
|
|
if(!$hiddenBefore) {
|
|
$linkResult .= $pageHidden;
|
|
$hiddenBefore = true;
|
|
}
|
|
else if(!$hiddenAfter && $i > $currentPage) {
|
|
$linkResult .= $pageHidden;
|
|
$hiddenAfter = true;
|
|
}
|
|
}
|
|
}
|
|
return $linkResult;
|
|
}
|
|
endif;
|
|
|
|
function stheme_get_paged() {
|
|
$paged = intval(get_query_var('paged')) ? intval(get_query_var('paged')) : 1;
|
|
return $paged;
|
|
}
|
|
|
|
function tao_custom_post_type()
|
|
{
|
|
$label = array(
|
|
'name' => __('Employees','thanhgiang'),
|
|
'singular_name' => __('Employee','thanhgiang')
|
|
);
|
|
$args = array(
|
|
'labels' => $label, //Gọi các label trong biến $label ở trên
|
|
'description' => 'Employee', //Mô tả của post type
|
|
'supports' => array(
|
|
'title',
|
|
'editor',
|
|
'excerpt',
|
|
'custom-fields'
|
|
), //Các tính năng được hỗ trợ trong post type
|
|
'hierarchical' => false, //Cho phép phân cấp, nếu là false thì post type này giống như Post, false thì giống như Page
|
|
'public' => true, //Kích hoạt post type
|
|
'show_ui' => true, //Hiển thị khung quản trị như Post/Page
|
|
'show_in_menu' => true, //Hiển thị trên Admin Menu (tay trái)
|
|
'show_in_nav_menus' => true, //Hiển thị trong Appearance -> Menus
|
|
'show_in_admin_bar' => true, //Hiển thị trên thanh Admin bar màu đen.
|
|
'menu_position' => 5, //Thứ tự vị trí hiển thị trong menu (tay trái)
|
|
'menu_icon' => 'dashicons-admin-users', //Đường dẫn tới icon sẽ hiển thị
|
|
'can_export' => true, //Có thể export nội dung bằng Tools -> Export
|
|
'has_archive' => false, //Cho phép lưu trữ (month, date, year)
|
|
'exclude_from_search' => false, //Loại bỏ khỏi kết quả tìm kiếm
|
|
'publicly_queryable' => true, //Hiển thị các tham số trong query, phải đặt true
|
|
'capability_type' => 'post' //
|
|
);
|
|
register_post_type('employee', $args);
|
|
}
|
|
add_action('init', 'tao_custom_post_type');
|
|
|
|
function tao_taxonomy() {
|
|
|
|
/* Biến $label chứa các tham số thiết lập tên hiển thị của Taxonomy
|
|
*/
|
|
$labels = array(
|
|
'name' => __('Departments','thanhgiang'),
|
|
'singular' => __('Department','thanhgiang'),
|
|
'menu_name' => __('Departments','thanhgiang')
|
|
);
|
|
|
|
/* Biến $args khai báo các tham số trong custom taxonomy cần tạo
|
|
*/
|
|
$args = array(
|
|
'labels' => $labels,
|
|
'hierarchical' => true,
|
|
'public' => true,
|
|
'show_ui' => true,
|
|
'show_admin_column' => true,
|
|
'show_in_nav_menus' => true,
|
|
'show_tagcloud' => true,
|
|
);
|
|
|
|
/* Hàm register_taxonomy để khởi tạo taxonomy
|
|
*/
|
|
register_taxonomy('department', array('employee'), $args);
|
|
|
|
}
|
|
// Hook into the 'init' action
|
|
add_action( 'init', 'tao_taxonomy', 0 );
|
|
|
|
function add_query_vars_filter( $vars ) {
|
|
$vars[] = "dep";
|
|
return $vars;
|
|
}
|
|
add_filter( 'query_vars', 'add_query_vars_filter' );
|
|
|
|
/**
|
|
@ Chèn CSS và Javascript vào theme
|
|
@ sử dụng hook wp_enqueue_scripts() để hiển thị nó ra ngoài front-end
|
|
**/
|
|
function thanhgiang_styles() {
|
|
/*
|
|
* Hàm get_stylesheet_uri() sẽ trả về giá trị dẫn đến file style.css của theme
|
|
* Nếu sử dụng child theme, thì file style.css này vẫn load ra từ theme mẹ
|
|
*/
|
|
wp_register_style( 'plugin-style', get_template_directory_uri() . '/css/plugin.css', 'all' );
|
|
wp_enqueue_style( 'plugin-style' );
|
|
|
|
wp_register_style( 'main-style', get_template_directory_uri() . '/css/main.css?v='.time(), 'all' );
|
|
wp_enqueue_style( 'main-style' );
|
|
|
|
wp_register_script( 'plugin-js', get_template_directory_uri() . '/js/plugin.js', array('jquery'),null,true );
|
|
wp_enqueue_script( 'plugin-js' );
|
|
|
|
wp_enqueue_script('params-js', get_template_directory_uri() . '/js/test.js');
|
|
wp_localize_script( 'params-js', 'my_ajax_object',array( 'ajax_url' => admin_url( 'admin-ajax.php' ),'siteurl' => get_option('siteurl') ));
|
|
wp_enqueue_script( 'params-js' );
|
|
wp_register_script( 'map-js', get_template_directory_uri() . '/js/map.js', array('jquery'),null,true );
|
|
wp_enqueue_script( 'map-js' );
|
|
|
|
wp_register_script( 'knockout-js', get_template_directory_uri() . '/js/knockout-3.4.2.js', array('jquery'),null,true );
|
|
wp_enqueue_script( 'knockout-js' );
|
|
wp_register_script( 'knockout-mapping-js', get_template_directory_uri() . '/js/knockout.mapping-latest.js', array('jquery') ,null,true);
|
|
wp_enqueue_script( 'knockout-mapping-js' );
|
|
wp_register_script( 'knockout-validation-js', get_template_directory_uri() . '/js/knockout.validation.min.js', array('jquery') ,null,true);
|
|
wp_enqueue_script( 'knockout-validation-js' );
|
|
wp_register_script( 'moment-js', get_template_directory_uri() . '/js/moment.min.js', array('jquery'),null,true );
|
|
wp_enqueue_script( 'moment-js' );
|
|
wp_register_script( 'bootstrap-datepicker-js', get_template_directory_uri() . '/js/bootstrap-datepicker.min.js', array('jquery'),null,true );
|
|
wp_enqueue_script( 'bootstrap-datepicker-js' );
|
|
wp_register_script( 'carousel-js', get_template_directory_uri() . '/js/owl.carousel.js', array('jquery'),null,true );
|
|
wp_enqueue_script( 'carousel-js' );
|
|
wp_register_script( 'main-js', get_template_directory_uri() . '/js/main.js', array('jquery'),null,true );
|
|
wp_enqueue_script( 'main-js' );
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'thanhgiang_styles' );
|
|
|
|
function booking_styles() {
|
|
wp_register_style('booking', get_template_directory_uri() . '/css/bootstrap-datepicker3.min.css', 'all');
|
|
$id = pll_get_post( 171 );
|
|
if(is_page($id)){
|
|
wp_enqueue_style('booking');
|
|
}}
|
|
add_action( 'wp_enqueue_scripts', 'booking_styles' );
|
|
//add fix
|
|
add_action( 'wp_enqueue_scripts', 'booking_styles' );
|
|
add_action( 'wp_enqueue_scripts', 'touchSwipe' );
|
|
function touchSwipe() {
|
|
$time = current_time( 'YmdHis' );
|
|
// // javascript
|
|
wp_enqueue_script('my-script', get_template_directory_uri() . '/js/jquery.touchSwipe.min.js?', array('jquery'), $time, true );
|
|
}
|
|
|
|
|
|
function register_daotao_menus() {
|
|
register_nav_menu('daotao-menu', __('Menu Đào tạo'));
|
|
}
|
|
add_action('after_setup_theme', 'register_daotao_menus');
|
|
|
|
|
|
// sửa từ đây
|
|
|
|
function register_daotao_02_menu() {
|
|
register_nav_menu('menu-daotao-02', __('menu-daotao-02'));
|
|
}
|
|
add_action('after_setup_theme', 'register_daotao_02_menu');
|
|
|
|
add_action('wp_ajax_load_category_posts', 'load_category_posts_callback');
|
|
add_action('wp_ajax_nopriv_load_category_posts', 'load_category_posts_callback');
|
|
function load_category_posts_callback() {
|
|
$cat_id = intval($_GET['cat_id']);
|
|
$query = new WP_Query([
|
|
'cat' => $cat_id,
|
|
'posts_per_page' => 10
|
|
]);
|
|
if($query->have_posts()) {
|
|
while($query->have_posts()) {
|
|
$query->the_post();
|
|
echo '<div class="post-item">';
|
|
echo '<a href="'.get_permalink().'">'.get_the_title().'</a>';
|
|
echo '<div>'.get_the_excerpt().'</div>';
|
|
echo '</div>';
|
|
}
|
|
} else {
|
|
echo '<p>Không có bài viết.</p>';
|
|
}
|
|
wp_die();
|
|
}
|