This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Ví dụ cho post_type là race | |
Thêm code dưới vào file functions.php | |
Chú ý nếu post type là "race" nhưng slug lại là "race-slug" thì cần thay lại dòng 17 như sau | |
$post_link = str_replace( '/race-slug/', '/', $post_link ); | |
*/ | |
/** | |
* Remove the slug from published post permalinks. Only affect our custom post type, though. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Hiển thị tối đa 12 ảnh mới nhất trong instagram cho user | |
Cách dùng: [instagram_widget user="_Your User Here_" show="_Your Number show (max 12)_"] | |
by www.levantoan.com | |
*/ | |
function scrape_instagram($username, $slice = 9) { | |
if (false === ($instagram = get_transient('instagram-photos-'.sanitize_title_with_dashes($username)))) { | |
$remote = wp_remote_get('http://instagram.com/'.trim($username)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Find html2element in | |
Version < 4.8: /wp-content/plugins/js_composer/assets/js/backend/composer-view.js | |
Version > 4.9: wp-content/plugins/js_composer/assets/js/dist/backend-actions.min.js | |
*/ | |
html2element: function(html) { | |
var attributes = {}, | |
$template; | |
if (_.isString(html)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID | |
FROM wp_posts | |
INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) | |
INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id ) | |
INNER JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) | |
INNER JOIN wp_postmeta AS mt3 ON ( wp_posts.ID = mt3.post_id ) | |
WHERE 1=1 | |
AND ( | |
wp_postmeta.meta_key = 'end_date' | |
AND |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
sắp xếp theo ID, những ID nào chẵn thì xếp tăng dần, ID lẻ thì giảm dần | |
VD: | |
5 | |
3 | |
1 | |
2 | |
4 | |
6 | |
Kết quả: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Nếu khi click vào thẻ a bật fancybox mà bị nhảy lên đầu trang thì bạn thêm đoạn script này vào là ok*/ | |
helpers: { | |
overlay: { | |
locked: false | |
} | |
} | |
Ví dụ thực tế: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_page_template_redirect(){ | |
global $post; | |
if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'your_short_code') && ! is_user_logged_in() ) { | |
wp_redirect(URL_IN_HERE); | |
exit(); | |
} | |
} | |
add_action( 'template_redirect', 'my_page_template_redirect' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Add to functions.php | |
*/ | |
function comment_validation_init() { | |
if(is_singular() && comments_open() ) { ?> | |
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
$('#commentform').validate({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).scroll(function(){ | |
var window_top = $(window).scrollTop(); | |
var div_top = $(".number_counter").offset().top + 50; // Change class .number_counter | |
var window_height = $(window).height(); | |
if (window_top + window_height >= div_top) { | |
//Code here | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$arg = array( | |
'post_type' => 'events',//thay bằng post type của bạn | |
'posts_per_page' => 3, | |
'orderby' => 'meta_value', | |
'meta_key' => 'start_date_event',//thay bằng meta key của bạn | |
'order' => 'ASC', | |
'meta_query' => array( | |
array( | |
'key' => 'start_date_event',//thay bằng meta key của bạn |