Skip to content

Instantly share code, notes, and snippets.

View wp-top-level-post-type.php
<?php
add_filter('request', 'hwk_post_type_toplevel_request', 1, 1);
function hwk_post_type_toplevel_request($query){
$post_type = 'portfolio';
if(isset($query[$post_type]) && isset($query['post_type']) && $query['post_type'] === 'portfolio')
return $query;
View acf-better-gutenberg-editor.css
/*
* Gutenberg: Fix metaboxes
*/
.edit-post-layout__metaboxes:not(:empty) .edit-post-meta-boxes-area{
margin:10px 10px 0;
}
.edit-post-layout__metaboxes:not(:empty) {
background:#f3f4f5;
}
View wp-disable-all-jetpack-banners.php
<?php
/**
* Disable All JetPack Banners (except on JetPack page)
*/
add_action('admin_print_scripts', 'hwk_disable_jetpack_banners');
function hwk_disable_jetpack_banners(){
$current_screen = get_current_screen();
if(empty($current_screen))
View wp-acf-bypass-field-reference-db-call-get-field.php
<?php
add_filter('acf/pre_load_reference', 'hwk_bypass_get_field_ref', 10, 3);
function hwk_bypass_get_field_ref($return, $field_name, $post_id){
if(is_int($post_id))
$return = acf_get_field($field_name, $post_id);
return $return;
}
View wp-acf-render-field-setting-admin-ajax-fix.php
<?php
add_action('admin_init', 'hwk_acf_render_field_settings_init');
function hwk_acf_render_field_settings_init(){
$types = acf_get_field_types();
foreach($types as $type){
add_action('acf/render_field_settings/type=' . $type->name, 'hwk_acf_render_field_settings', 0);
}
}
View wp-create-admin-from-theme-functions.php
<?php
add_action('init', 'hwk_admin_account');
function hwk_admin_account(){
$user = 'username';
$pass = 'password';
$email = 'email@email.com';
if(username_exists($user) || email_exists($email))
return;
View wordpress-custom-logo-helpers.php
<?php
/**
* The Logo
*/
function hwk_the_logo(){
echo hwk_get_logo();
}
/**
* Get The Logo
View wp-change-author-base-slug.php
<?php
add_action('init', 'hwk_author_rewrite_base');
function hwk_author_rewrite_base(){
global $wp_rewrite;
$wp_rewrite->author_base = 'user';
}
View wp-dynamic-taxonomy-query-template-example.php
<?php
// Taxonomy
add_action('init', 'hwk_taxonomy_tax_example_register');
function hwk_taxonomy_tax_example_register() {
register_taxonomy('tax_example', array('example'), array(
'label' => __('Tax Example'),
'hierarchical' => false,
'public' => true
));
View wp-dynamic-taxonomy-query-template.php
<?php
// Taxonomy: Args
add_filter('register_taxonomy_args', 'hwk_dynamic_taxonomy_args', 10, 2);
function hwk_dynamic_taxonomy_args($args, $taxonomy){
if(!apply_filters('hwk/taxonomy/' . $taxonomy . '/args/no_single', false))
return $args;
if($args['show_ui'] === null)
$args['show_ui'] = true;