Skip to content

Instantly share code, notes, and snippets.

View mennwebs's full-sized avatar

Menn mennwebs

View GitHub Profile
@mennwebs
mennwebs / functions.php
Created March 22, 2020 10:20
Add Category Name to body_class
/* Add Category Name to body_class */
add_filter('body_class','moss_add_category_to_single');
function moss_add_category_to_single($classes) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
$classes[] = 'category-' . $category->category_nicename;
}
}
@mennwebs
mennwebs / page-account.php
Last active March 27, 2020 14:50
Show User Meta from WordPress
<?php $user = wp_get_current_user();?>
<h3 class="name"><?php echo $user->first_name . ' ' . $user->last_name;?></h3>
<div class="profile">
<div class="contact">
<p><?php echo $user->user_email; ?></p>
<p><?php echo $user->billing_phone; ?></p>
</div>
<div class="address">
<p>
<?php
@mennwebs
mennwebs / wp-config.php
Last active March 31, 2020 12:11
Mailgun for WP Multisite
<?php
// Ref: https://guides.wp-bullet.com/how-to-use-mailgun-with-wordpress-multisite-http-api-or-smtp/
//Mailgun multisite stuff
define('MAILGUN_USEAPI', true);
define('MAILGUN_APIKEY', 'key-YourAPIKeyHere');
define('MAILGUN_DOMAIN', 'mg.youdomain.com' );
define('MAILGUN_SECURE', true);
// Set the from name and from address
@mennwebs
mennwebs / thai-province.txt
Created May 31, 2020 13:12
The Province Name
กระบี่
กรุงเทพมหานคร
กาญจนบุรี
กาฬสินธุ์
กำแพงเพชร
ขอนแก่น
จันทบุรี
ฉะเชิงเทรา
ชลบุรี
ชัยนาท
@mennwebs
mennwebs / wp-config.php
Created September 4, 2020 01:46
Default Theme for Multisite
<?php
// Set the Default Theme for WordPress Multisite
define( 'WP_DEFAULT_THEME', 'plant' );
@mennwebs
mennwebs / functions.php
Created September 5, 2020 05:41
Create Home Page and set as home.
<?php
function sw_setup() {
if(get_option('page_on_front')=='0' && get_option('show_on_front')=='posts') {
// Create homepage
$homepage = array(
'post_type' => 'page',
'post_title' => 'Home',
'post_content' => '',
'post_status' => 'publish',
'post_author' => 1
@mennwebs
mennwebs / functions.php
Created September 12, 2020 07:49
The SEO Framework - Limit only 1 image for social sharing
<?php
// from https://github.com/sybrew/the-seo-framework/issues/541
add_filter( 'the_seo_framework_image_generation_params', function( $params ) {
unset( $params['cbs']['content'] );
return $params;
} );
@mennwebs
mennwebs / acf-datepicker.js
Created January 27, 2021 09:29
ACF override minDate, maxDate in datepicker
jQuery(document).ready(function ($) {
acf.add_filter("date_picker_args", function (args, $field) {
if ($field.hasClass("birth_date")) {
args["minDate"] = "-8y"; //ref: https://api.jqueryui.com/datepicker/
args["maxDate"] = "-1d";
}
return args;
});
});
@mennwebs
mennwebs / single.php
Created March 1, 2021 11:22
Show related post from "Related Posts for WordPress By Never5" WordPress Plugin
<?php // Show related post from "Related Posts for WordPress By Never5" WordPress Plugin
$p_id = get_the_ID();
$link_args = array(
'post_type' => 'rp4wp_link',
'posts_per_page' => 6,
'meta_query' => array(
array(
'key' => 'rp4wp_parent',
@mennwebs
mennwebs / functions.php
Last active July 22, 2021 06:57
WP Shortcode for sending to Line Notify [s_line]
<?php
add_action( 'forminator_form_after_handle_submit', 'ws_get_message', 10, 2 );
add_action( 'forminator_form_after_save_entry', 'ws_get_message', 10, 2 );
// เก็บข้อความจากฟอร์มแล้วส่งไลน์
function ws_get_message($form_id, $response) {
// ===แก้ตรงนี้=====