tag:blogger.com,1999:blog-1287437365879668392024-03-29T10:29:53.419+07:00Thiết kế website bằng wordpress, thiết kế website bằng wordpress giá rẻThiết kế website bằng wordpress, thiết kế web chuyên nghiệp, uy tín, bảo hành trọn đời, với giá: 500k, 750k, 900k. LH:0909.257.034Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-128743736587966839.post-35892041888064211112013-12-11T20:37:00.003+07:002013-12-11T20:41:06.073+07:00Hiển thị bài POST với điều kiện của meta_box hay custom fieldBài toán đặt ra: Viết chức năng của bài post gồm có: nút check, những bài viết nào mà được checked thì mới hiện thi ra trang chủ. Để viết được nút check box thì bạn dùng custom field, hay meta_box (bài này mình sẽ hướng dẫn sau)
Để hiện thị những bài viết nào mà được checked trong admin thì bạn hiểu đơn giản sau: ví dụ mình có 1 check box như sau
<input type="checkbox" name="is_home" value="Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com5tag:blogger.com,1999:blog-128743736587966839.post-79915519067056504622013-12-07T08:30:00.001+07:002013-12-07T08:30:28.376+07:00Hướng dẫn viết Wedget trong - viết theme trong wordpress
B1: Vào wp-content/themes, tạo cấu trúc theme như sauB2: Mở file wp-content/themes/nhatnghe/style.css, khai báo đạon code comment sauLưu ý: nhatnghe là tên theme đang thiết kếB3: Trang quản trị Wordpress, chọn "Appearance/Themes"- Tìm và kích hoạt theme nhatnghe đang thiết kếB4: Mở trang wp-content/themes/nhatnghe/index.php, trước </head>, chèn Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-8328175194387567372013-12-07T08:27:00.002+07:002013-12-07T08:27:34.062+07:00Viết shortcode trong wordpressYêu cầu: Kết nối cơ sở dữ liệu, hiện danh sách dữ liệu lên site Chuẩn bị:Cài wordpress Tạo bảng wp_hocsinh Nhập dữ liệu. B1: Tạo cấu trúc cho plugin như sau:B2: Mở wp-content/plugins/quanlyhocsinh/index.php, gõ code sau:Lưu ý: QuanLyHocSinh là tên plugin đang thiết kếB3: Vào trang quản trị WordPress, chọn Plugins/Installed Plugins- Click “Activate” plugin QuanLyHocSinhB4: Mở file wp-content/Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-73678150998275497152013-12-05T10:00:00.001+07:002013-12-05T10:03:43.234+07:00Lấy POST theo post_meta, taxonomy trong wordpress
Ví dụ: trong website có chức năng hiển thị bài viết theo user.
User đó đăng nhập muốn xem những bài viết của mình (id_user được lưu trong meta_post).
Để hiển thị những bài post(bảng post) theo user (bảng metapost) thì chúng ta dùng đoạn code sau
$args = array(
'post_type' => "buy_a_franchise",
'post_status' => array('publish', 'pending', 'draft', 'auto-draft'Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-8485839477506731312013-11-29T09:48:00.001+07:002013-11-29T09:50:00.607+07:00add_image_size thêm kích thước ảnh mới trong wordpress
Tùy theo theme mà có kích thước ảnh khác nhau. Các ảnh này được resize theo 1 kích thước đã được khai báo trong file functions.php
Trong quá trình viết theme, bạn cần bổ sung 1 hình có kích thước mới ví dụ 152 X 92 pixels
Trong wordpress hỗ trợ tốt chúng ta trong phần này
add_image_size('franchise-thumbnailsAnonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-72834884362572000132013-11-20T09:34:00.002+07:002013-11-20T09:34:26.574+07:00Sắp xếp post type trong admin wordpressMặc định bạn tạo ra 1 post type mới, danh sách các bài post sẽ sắp xếp theo 1 thứ tự mặc định (theo tiêu đề ASC). Bạn muốn tùy chỉnh việc sắp xếp này, có thể theo tiêu đề, theo ID, theo ngày
Tham khảo mẫu code dưới đâu. Code này được chèn trong file functions.php (hoặc kèm trong 1 plugin của bạn)
function set_custom_post_types_admin_order($wp_query) {
if (is_admin())Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-90615201841471346062013-11-06T16:29:00.003+07:002013-11-06T16:30:09.695+07:00Wordpress Upload Image from front-end and get its urlfunction agp_process_woofile($files, $post_id, $caption){
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
$attachment_id = media_handle_upload($files, $post_id);
$attachment_url = wp_get_attachment_url($attachment_id);
add_post_meta($post_id, 'Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-29276310422965573102013-10-30T11:07:00.000+07:002013-10-30T11:07:46.574+07:00Hiển thị danh sách "post_type" trong wordpress
Hàm lấy danh sách post type theo tên post_type
<?php
$args = array(
'numberposts' => 0,
'post_type' => 'country-origin'
&Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-73829214204139750312013-10-30T10:46:00.000+07:002013-10-30T10:46:09.258+07:00Wordpress lấy danh mục - get categories
Description
Returns an array of category objects matching the query parameters.
Arguments are pretty much the same as wp_list_categories and can be passed as either array or in query syntax.
Usage
<?php $categories = get_categories( $args ); ?>
Default Usage
<?php
$args = array(
'type' => 'post',
'Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-47906481414779653402013-10-29T16:26:00.002+07:002013-10-29T16:27:32.784+07:00WordPress & jQuery Contact Form without a Plugin
There are lots of WordPress plugins for contact forms, but wouldn’t it be nice to have more control over the markup? In this tutorial, I am going to show how to use a custom page template to create a contact form in WordPress without a plugin.
Some people may want to skip the post and get to the demo and source files:
View Demo Download Source Files
So, why not use a plugin?
Well, I thinkAnonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com3tag:blogger.com,1999:blog-128743736587966839.post-51161777077047964282013-10-29T15:29:00.001+07:002013-10-29T15:31:41.545+07:00Tạo form liên hệ trong wordpress không dùng plugin
How to Create a WordPress Contact Form Without a Plugin
There are a lot of different plugins available to put a contact form on your WordPress site, but I like to use as few plugins as i can get away with. So if you feel the same way, here’s a simple way to add a contact form, with some simple cut & paste of your site’s existing page.php file.
First step – Create your page template
Copy Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-55802243422895590232013-10-28T13:52:00.001+07:002013-10-28T13:52:12.931+07:00Giới thiệu 1 số hàm kiểm tra trong wordpress
Function: is_404()
Function: is_admin()
Function: is_admin_bar_showing()
Function: is_archive()
Function: is_attachment()
Function: is_author()
Function: is_category()
Function: is_comments_popup()
Function: is_date()
Function: is_day()
Function: is_feed()
Function: is_front_page()
Function: is_home()
Function: Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-88832457525519748202013-10-28T13:32:00.000+07:002013-10-28T13:32:57.246+07:00Query lấy 1 dòng trong wordpress
Trong wordpress, bạn muốn lấy dữ liệu từ database, và bạn muốn lấy chỉ 1 dòng record thôi.
Ví dụ: Lấy tên người dùng, lấy chi tiết bài viết:
global $wpdb;
$wrp_table = $wpdb->prefix . 'wrp';
$query = "SELECT * FROM $wrp_table WHERE id = " . $_GET['id'];
$data = $wpdb->get_row($query);
Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-31450703687232651902013-10-28T09:38:00.001+07:002013-10-28T10:21:55.362+07:00Câu lệnh insert trong wordpressĐể insert một dữ liệu trong wordpress như sau
<?php
$wpdb->insert($wpdb->prefix . 'wrp', $settings);
?>
Tham số thứ 1: là tên bảng
Tham số thứ 2: là 1 mảng các giá trị
Mảng đó như sau, ví dụ:
$settings['name'] = $_POST['name'];
$settings['key_active'] &Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com0tag:blogger.com,1999:blog-128743736587966839.post-65991186578203491802013-10-28T09:30:00.000+07:002013-10-28T10:20:26.127+07:00Chuyển hướng (redirect) trong wordpress
Để chuyển hướng trong wordpress, bạn sử dụng hàm sau:
<?php wp_redirect( $location, $status ); exit; ?>
$location: là một URL
$status: Mặc định là 302
Ví dụ:
<?php wp_redirect( home_url() ); exit; ?>
<?php wp_redirect( 'http://www.example.com', 301 ); exit; ?>
Anonymoushttp://www.blogger.com/profile/16756597878489121634noreply@blogger.com18