Skip to content

Instantly share code, notes, and snippets.

@phucdohong96
phucdohong96 / Function.php
Created November 4, 2017 05:03
Loop with custom pagination ajax
<?php
function pager_loop_function() {
ob_start();
$paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1;
$args1 = array(
'post_type' => 'post',
'paged' => $paged1,
'posts_per_page' => 6,
);
@phucdohong96
phucdohong96 / Function.php
Created November 4, 2017 04:47
Get ID from previous page
<?php
function get_featured_image_func() {
$postid = url_to_postid( $_SERVER['HTTP_REFERER'] );
$image = get_field('featured_image', $postid);
$image = '<img src="'.$image["url"].'" />';
return $image;
}
add_shortcode( 'get_featured_image_shortcode', 'get_featured_image_func' );
@phucdohong96
phucdohong96 / shortcode.php
Created November 3, 2017 08:11
Form submit link to facetwp filter
<?php
//resource_home_filter_function
function resource_home_filter_function() {
ob_start();
?>
<form method="get" action="/resources/" class="home_filter_form nobottommargin">
<div class="select_filter">
<select name='fwp_product_category' id='fwp_product_category' class='distributor_market' >
<option value='' selected='selected'>Document Categories</option>
<?php
@phucdohong96
phucdohong96 / shortcode.php
Last active November 4, 2017 04:51
Shortcode Filter Product Category And Product
<?php
//Product_home_filter_function
function product_home_filter_function() {
ob_start();
//Get category outside loop
$terms = get_terms( 'product_category' );
$select_categories = '';
$script_product1 = '';
$script_product2 = '';
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB72d431DELv-7l45MlWBDBJH6XxPieMGU">
</script>
<script>
function initMapHCM() {
var center = new google.maps.LatLng(10.793270, 106.687616);
var map = new google.maps.Map(document.getElementById('map_hcm'), {
zoom: 16,
@phucdohong96
phucdohong96 / method1.php
Last active September 27, 2017 03:15
Check duplicate values in PHP array
<?php
/*Check duplicate values in PHP array*/
$country_array = [];
$args = array(
'post_type' => 'distributor',
'posts_per_page' => '-1'
);
$loop = new WP_Query($args);
while($loop->have_posts()): $loop->the_post();
$id = get_the_ID();
@phucdohong96
phucdohong96 / shortcode.php
Last active November 4, 2017 04:53
Shortcode Category Menu With Post Object ACF
<?php
function custom_taxonomer(){
$wp_post_types = get_post_type();
if($wp_post_types == 'product'){
$languages = [];
$types = [];
echo '<h3>Documents</h3>';
$documents = get_field('document_uploads');
foreach ($documents as $key => $value) {
$resource_language = wp_get_post_terms($value->ID, 'resource_language', true);
@phucdohong96
phucdohong96 / shortcode_post_object.php
Created August 24, 2017 04:21
Shortcode Sample ACF Post Object & ACF Repeater
<?php
function shortcode_post_object_function() {
ob_start();
$count = 0;
//Get field
$post_objects = get_field ('post_objects');
if (!empty($post_objects)) {
foreach ($post_objects as $post_object) {
$id = $post_object->ID;
var $ = jQuery.noConflict();
@phucdohong96
phucdohong96 / Function.php
Created July 6, 2017 10:15
Equal height column bootstrap
<?php
add_action('init', 'custom_header_scripts'); // Add Custom Scripts to wp_head
// Load scripts (header.php)
function custom_header_scripts()
{
wp_register_script('equal-height', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.matchHeight/0.7.0/jquery.matchHeight-min.js', array('jquery'), '1.0.0');
wp_enqueue_script('equal-height'); // Enqueue it!
wp_register_script('scripts', plugins_url('/js/scripts.js', __FILE__), array('jquery'), '1.0.0');