Skip to content

Instantly share code, notes, and snippets.

View woraperth's full-sized avatar
🏠
Working from home

Perth Ngarmtrakulchol woraperth

🏠
Working from home
View GitHub Profile
<form role="search" method="get" id="searchform"
class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div>
<label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label>
<input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit"
value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" />
</div>
</form>
@woraperth
woraperth / template-functions.php (for CPT)
Last active August 1, 2024 23:46
[WordPress] Add ACF Admin Column to Custom Post Type (In this example, CPT name = events & ACF column name = event_date). This also make the column sortable.
// Add ACF Columns
function add_new_events_column($columns) {
$columns['event_date'] = 'Event Date';
return $columns;
}
add_filter('manage_events_posts_columns', 'add_new_events_column');
function add_new_events_admin_column_show_value( $column, $post_id ) {
if ($column == 'event_date') {
@woraperth
woraperth / note.md
Created December 29, 2018 11:32
How to install WordPress Project built in MAMP, on Local by Flywheel
  1. Create project in Local by Flywheel
  2. Pull git project to ~/Local Sites/(project name)/app/public
  3. Go to Local by Flywheel, right click the project > Open Site SSH
  4. cd ./app/public folder
  5. Import the database using: wp db import xxxxx (If it comes in .sql.gz form, we may need to run 'gunzip' on the file first)
@woraperth
woraperth / custom_schema.py
Created June 21, 2020 11:58
PySpark: Set Custom Schema
# Reference: https://stackoverflow.com/questions/57901493/pyspark-defining-custom-schema-for-a-dataframe
table_schema = StructType([StructField('ID', StringType(), True),
StructField('Name', StringType(), True),
StructField('Tax_Percentage(%)', IntegerType(), False),
StructField('Effective_From', TimestampType(), False),
StructField('Effective_Upto', TimestampType(), True)])
df = spark.read.format(file_type) \
.option("header", "true") \