Skip to content

Instantly share code, notes, and snippets.

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

krystyna krystyna93

🏠
Working from home
  • Victoria, Australia
View GitHub Profile
@josanua
josanua / wp-code-utils.php
Last active October 25, 2024 03:58
wp code utils
<?php
************ Debug, Debuging ************
//Activate log files in wp-config.php
define( 'WP_DEBUG', true ); // Enabling WP_DEBUG will cause all PHP errors, notices and warnings to be displayed.
define( 'WP_DEBUG_LOG', true ); // Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_DISPLAY', true ); // Controls whether debug messages are shown inside the HTML of pages or not.
// use this
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
<?php
class My_Dropdown_Category_Control extends WP_Customize_Control {
public $type = 'dropdown-category';
protected $dropdown_args = false;
protected function render_content() {
?><label><?php
@bestwebsite
bestwebsite / functions.php
Created August 11, 2017 00:21
Add featured image column to WordPress admin post and page lists
add_image_size( 'bestwebsite-admin-post-featured-image', 120, 120, false );
// Add the posts and pages columns filter. They can both use the same function.
add_filter('manage_posts_columns', 'bestwebsite_add_post_admin_thumbnail_column', 2);
add_filter('manage_pages_columns', 'bestwebsite_add_post_admin_thumbnail_column', 2);
// Add the column
function bestwebsite_add_post_admin_thumbnail_column($bestwebsite_columns){
$bestwebsite_columns['bestwebsite_thumb'] = __('Featured Image');
return $bestwebsite_columns;
@Auke1810
Auke1810 / wpa-clean-header.php
Last active August 5, 2026 13:30
create a clean wordpress header and remove unnecessary clutter.
<?php
/*
Plugin Name: wordpress assist clean header
Plugin URI: http://www.wordpressassist.nl/
Description: Remove shortlink hook
Version: 1.0
Author: AukeJomm
Author URI: http://www.aukejongbloed.nl
*/
<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty
<?php
/**
* @package Smashing_plugin
* @version 1.0
*/
/*
Plugin Name: Smashing plugin
Plugin URI: https://www.smashingmagazine.com/2016/03/advanced-wordpress-search-with-wp_query/
Description: This is an example plugin for Smashing Magazine readers.
Author: Carlo Daniele
@cferdinandi
cferdinandi / metabox-single.php
Last active March 15, 2023 01:33
Create a metabox with a single field
<?php
/**
* Create a metabox with a single field.
* Replace `_namespace` with some namespace for your project to avoid conflicts with other items
*/
//
// Create Metabox
//
@kosso
kosso / custom-types-and-fields.php
Last active March 30, 2025 08:12
An example Wordpress (4.7+) plugin to create custom post types with custom taxonomies and custom meta fields, including exposing these to the REST API and adding custom columns in admin.
<?php
/**
* Plugin Name: Custom Post Types Example
* Description: An example plugin to create custom post types with custom taxonomies and custom meta fields, including exposing to the REST API.
* Plugin URI: http://kosso.co.uk
* Version: 1.0.0
* Author: Kosso
* Author URI: http://kosso.co.uk
* License: GPLv2
* Network: true
@dasbairagya
dasbairagya / front-end-to-cpt.php
Created December 27, 2016 06:46
How to add post from front-end form to custom post type in admin back-end
<?php
/**
* template name: blogupdate
* Created by PhpStorm.
* User: PC35
* Date: 25-10-2016
* Time: 16:04
*/
global $wpdb;
$id= get_current_user_id();