Skip to content

Instantly share code, notes, and snippets.

@phucdohong96
phucdohong96 / Function.php
Last active October 7, 2017 05:49
Custom Loop With Muilti Pagination
<?php
include('cutom_loop_shortcode.php');
add_shortcode('loop_custom_shortcode', 'loop_custom_function');
@phucdohong96
phucdohong96 / Function.php
Last active October 7, 2017 05:49
Custom Loop Pagination
<?php
include('cutom_loop_shortcode.php');
add_shortcode('loop_custom_shortcode', 'loop_custom_function');
@phucdohong96
phucdohong96 / Function.php
Last active November 30, 2017 09:07
Example Create Shortcode WordPress
<?php
function custom_loop_function( $atts ) {
ob_start();
$opts = shortcode_atts( array(
'type' => 'post_type_option',
), $atts );
$output = '';
$args = array(
'post_type' => $opts['type'],
'posts_per_page' => '10',
@phucdohong96
phucdohong96 / toogle-text.js
Last active June 9, 2017 09:06
jQuery hide and show toggle div with read more - read less
jQuery(document).ready(function(){
jQuery(".content_toggle").hide();
jQuery(".toggle_box").on("click", function(){
jQuery(this).prev('.content_toggle').slideToggle(200);
jQuery(this).html(jQuery(this).html() == '<strong>Show More</strong>' ? '<strong>Show Less</strong>' : '<strong>Show More</strong>');
});
});
@phucdohong96
phucdohong96 / Wordpress.php
Last active August 26, 2017 04:33
Function get image wordpress
<?php
$id = get_the_ID ();
// Add Thumbnail Theme Support
add_theme_support('post-thumbnails');
add_image_size('large', 700, '', true); // Large Thumbnail
add_image_size('medium', 250, '', true); // Medium Thumbnail
add_image_size('small', 120, '', true); // Small Thumbnail
add_image_size('custom-size', 700, 200, true); // Custom Thumbnail Size call using the_post_thumbnail('custom-size');
/*
Get image with custom size: small, thumbnail, medium, large, full, array(custom_width,custom_height)
@phucdohong96
phucdohong96 / Function.php
Last active June 9, 2017 04:26
jQuery toggle excerpt
<?php
jQuery(document).ready(function() {
// Configure/customize these variables.
var showChar = 160; // How many characters are shown by default
var ellipsestext = "...";
var moretext = "Read more";
var lesstext = "Close";
jQuery('.more').each(function() {
<?php
/*Get Latest Post New*/
add_shortcode('content_slider', 'getPostSlide');
/**
*
*/
function getPostSlide($atts)
{
ob_start();
$args = array(
@phucdohong96
phucdohong96 / Function.php
Last active May 23, 2016 09:49
Hàm thêm dấu chấm (.) vào một chuỗi số hàng ngàn
<?php
function adddotstring($strNum) {
$len = strlen($strNum);
$counter = 3;
$result = "";
while ($len - $counter >= 0)
{
$con = substr($strNum, $len - $counter , 3);
$result = '.'.$con.$result;
@phucdohong96
phucdohong96 / ScriptTopFacet.js
Last active January 12, 2016 03:03
How to Add Pagination Scrolling
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
$('html, body').animate({
scrollTop: $('.facetwp-template').offset().top
}, 500);
});
})(jQuery);
</script>
@phucdohong96
phucdohong96 / facetwp.php
Last active December 30, 2015 02:30
Check Premium Listing thi cac bai Post len Top xep theo thu tu ABC
<?php
return array(
"post_type" => "hotel",
"post_status" => "publish",
"meta_key" => "premium_listing",
"orderby" => array( "meta_value_num" => "DESC", "title" => "ASC" ),
"posts_per_page" => 10,
);