Skip to content

Instantly share code, notes, and snippets.

View jimmy89Li's full-sized avatar

Li jimmy89Li

View GitHub Profile
@jimmy89Li
jimmy89Li / functions.php
Created December 3, 2015 13:46
Add background option in Appearance WordPress Admin Menu
// Register custom background = add background option in Appearance WordPress Admin Menu
add_theme_support( 'custom-background', array(
'default-color' => 'e6e6e6',
) );
@jimmy89Li
jimmy89Li / functions.php
Created December 3, 2015 13:45
Add menu option in Appearance WordPress Admin Menu
<?php
// Register wp_nav_menu() = add menu option in Appearance WordPress Admin Menu
register_nav_menu( 'primary', __( 'Primary Menu', 'fablabtheme' ) );
?>
@jimmy89Li
jimmy89Li / functions.php
Created December 3, 2015 13:25
Remove WordPress version
<?php
// Remove WordPress version
remove_action('wp_head', 'wp_generator');
?>
@jimmy89Li
jimmy89Li / functions.php
Last active December 3, 2015 15:29
WP CSS loaded from frunctions.php
<?php
wp_register_style(
'style',
get_template_directory_uri() . 'style.css',
array( 'theme-style' ),
'1.0',
'screen'
);
@jimmy89Li
jimmy89Li / PersonalInformationWidget.php
Created October 4, 2015 23:56
Custom Personal Information Widget for Footer
<?php
/*
Plugin Name: Personal Information Widget for Footer
Plugin URI: https://gist.github.com/jimmy89Li
Description: Custom widget for personal information
Author: jimmyLi
Version: 1.0.0
Author URI: https://gist.github.com/jimmy89Li
*/
@jimmy89Li
jimmy89Li / footer.php
Created October 4, 2015 21:31
WordPress footer with 3 widget areas
.hyphenate {
overflow-wrap: break-word;
word-wrap: break-word;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@jimmy89Li
jimmy89Li / favicon-function.php
Last active September 16, 2015 08:13
PHP code inside functions.php to load facivon.ico file as your website favicon
//add a favicon for your WordPress website
function blog_favicon() {
//this will load the favicon from the root directory of your blog
// echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('wpurl').'/favicon.ico" />';
//this will load the favicon from the root directory of your theme
echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('stylesheet_directory').'/favicon.ico" />' . "\n";
}
@jimmy89Li
jimmy89Li / get-parent-style-function.php
Last active September 16, 2015 07:36
PHP code inside functions.php to load parent's style.css in a WordPress child theme
<?php
add_action( 'wp_enqueue_scripts', 'parent_style_enqueue' );
function parent_style_enqueue() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
@jimmy89Li
jimmy89Li / fixed-top-menu.css
Last active September 16, 2015 07:40
CSS code for a menubar displayed always on top of the website page, even after scrolling down.
.menubar{
height:50px;
background-color: teal;
border-bottom: 2px solid black;
position: fixed;
width: inherit;
top: 0;
}