Skip to content

Instantly share code, notes, and snippets.

function register_post_types() {
//this is where you can register custom post types
function custom_posts($name, $single, $menu_order, $meta_cap, $capability_type, $supports, $taxonomies) {
register_post_type( $name, array(
'labels' => array(
'name' => _x( ucfirst($name), 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( ucfirst($single), 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( ucfirst($name), 'text_domain' ),
'name_admin_bar' => __( ucfirst($name), 'text_domain' ),
),
UPDATE `--database-name--`.wp_users SET user_pass = md5('--type the new password here--') WHERE user_login = 'pixel';
@kisabelle
kisabelle / acf-php-to-json.php
Created February 6, 2018 22:37
Convert ACF Fields Registered by PHP to Importable JSON Format
$groups = acf_get_local_field_groups();
$json = [];
foreach ($groups as $group) {
// Fetch the fields for the given group key
$fields = acf_get_local_fields($group['key']);
// Remove unecessary key value pair with key "ID"
unset($group['ID']);
@kisabelle
kisabelle / acf-php-to-json.php
Created February 6, 2018 22:37
Convert ACF Fields Registered by PHP to Importable JSON Format
$groups = acf_get_local_field_groups();
$json = [];
foreach ($groups as $group) {
// Fetch the fields for the given group key
$fields = acf_get_local_fields($group['key']);
// Remove unecessary key value pair with key "ID"
unset($group['ID']);
function custom_meta_box_markup()
{
// custom meta box markup goes here
}
function add_custom_meta_box()
{
add_meta_box("demo-meta-box", "Custom Meta Box", "custom_meta_box_markup", "post", "side", "high", null);
}
@kisabelle
kisabelle / disallow-file-edit.php
Created October 17, 2017 18:52
Disable File Editor in wp-config.php
define( 'DISALLOW_FILE_EDIT', true );
# Restrict direct access to PHP files from theme or plugin directories
# Place in root .htaccess file
# Restrict direct access to PHP files from plugin directories
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/
RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L]
@kisabelle
kisabelle / wp-change-display-name-existing-users.php
Created January 14, 2016 19:32
WordPress Change Default Display Name Publicy As First Name Last Name for all existing users
<?php
// Sets the user's display name (always) to first name last name, when it's avail.
add_action ('admin_head','make_display_name_f_name_last_name');
function make_display_name_f_name_last_name(){
$users = get_users(array('fields'=>'all'));
foreach($users as $user){
$user = get_userdata($user->ID);
@kisabelle
kisabelle / acf-pagination.php
Last active May 8, 2024 15:41
ACF Repeater Field Pagination
<?php
/*
* Paginate Advanced Custom Field repeater
*/
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
$page = 1;
}
@kisabelle
kisabelle / wp-pages-in-search.php
Created July 9, 2014 22:53
Add Pages to Wordpress Search Results
function my_custom_search_filter( $query ) {
if ( $query->is_search ) {
$query->set( 'post_type', array('post','page') );
}
return $query;
}
add_filter('pre_get_posts','my_custom_search_filter');