Skip to content

Instantly share code, notes, and snippets.

View mennwebs's full-sized avatar

Menn mennwebs

View GitHub Profile
@mennwebs
mennwebs / functions.php
Last active July 24, 2019 14:08
Auto CSS version for child theme.
<?php
/**
* Enqueue scripts and styles.
*/
function fruit_scripts() {
wp_dequeue_style( 'seed-style');
wp_enqueue_style( 'fruit-css', get_stylesheet_directory_uri() . '/style.css', array(), filemtime( get_stylesheet_directory() . '/style.css' ) );
wp_enqueue_script( 'fruit-js', get_stylesheet_directory_uri() . '/js/main.js', array(), '2017-1', true );
@mennwebs
mennwebs / front-page.php
Created April 12, 2018 06:12
ACF - Show product by Brand and Product_cat Taxonomy
<?php
if( have_rows($brand_slug) ):
$i = 1;
while( have_rows($brand_slug) ):
the_row();
$cat = $brand_slug . '-cat';
$term = get_sub_field($cat);
?>
<div class="tab-products">
@mennwebs
mennwebs / .htaccess
Last active January 1, 2018 05:17
force HTTPS - เพิ่มไว้บนสุดของไฟล์ได้เลย
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
@mennwebs
mennwebs / functions.php
Created July 24, 2017 14:29
WordPress - Redirect Login to /account/ page
<?php
function seed_login_redirect(){
global $pagenow;
if('wp-login.php' == $pagenow) {
if(isset($_POST['wp-submit']) || // in case of LOGIN
(isset($_GET['action']) && $_GET['action']=='logout') || // in case of LOGOUT
(isset($_GET['checkemail']) && $_GET['checkemail']=='confirm') || // in case of LOST PASSWORD
(isset($_GET['checkemail']) && $_GET['checkemail']=='registered')) return; // in case of REGISTER
else wp_redirect(home_url('/account/')); // or wp_redirect(home_url('/login'));
@mennwebs
mennwebs / single.php
Last active July 24, 2017 03:56
แสดง custom field ทั้งหมดใน WordPress Loop
<pre>
<small>
<?php
$cf = get_post_custom($post->ID);
print_r($cf);
?>
</small>
</pre>
@mennwebs
mennwebs / 0_reuse_code.js
Last active August 29, 2015 14:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console