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: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: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 / header.php
Created December 8, 2015 10:13
If logged-in see Menu1. Else Menu2.
<?php
if( is_user_logged_in() ) {
$menu = 'Menu1';
} else {
$menu = 'Menu2';
}
wp_nav_menu( array( 'menu' => $menu, 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );
?>
@jimmy89Li
jimmy89Li / functions.php
Created March 31, 2016 21:37
Show Admin Bar Fix In WordPress
if(is_user_logged_in()) {
add_filter('show_admin_bar', '__return_true', 1000);
}
@jimmy89Li
jimmy89Li / functions.php
Created April 10, 2016 12:55
Create a custom post type in WordPress (called Press) with Featured Image option included
<?php
// Create custom press posts
add_action( 'init', 'create_posttype' );
add_theme_support('post-thumbnails');
add_post_type_support( 'press', 'thumbnail' ); // Add Featured Image for Press Posts
function create_posttype() {
register_post_type( 'press',
array(
'labels' => array(
'name' => __( 'Press' ),
@jimmy89Li
jimmy89Li / autoReload.js
Created July 14, 2016 08:36
Auto reload the page every 30s
<!-- Auto reload the page every 30s -->
function pageRefresh(refreshTime) {
setTimeout("location.reload(true);",refreshTime);
}
window.onload = pageRefresh(30000);
@jimmy89Li
jimmy89Li / noDuplicates.js
Created July 19, 2016 14:24
remove duplicate divs based on their id
$('[id]').each(function (i) {
$('[id="' + this.id + '"]').slice(1).remove();
});
@jimmy89Li
jimmy89Li / CustomTextWidget.php
Created July 26, 2016 08:01
Custom Text Widget
<?php
/*
Plugin Name: Custom Text Widget
Plugin URI: https://gist.github.com/jimmy89Li
Description: Custom Text Widget with an Image from url, Title and Content
Author: jimmyLi
Version: 1.0.0
Author URI: https://liviusimion.com
*/
@jimmy89Li
jimmy89Li / custom-editor-style.css
Created August 2, 2016 11:50
Custom Font on Editor View
@import url(//fonts.googleapis.com/css?family=Open+Sans);
body {font-family: 'Open Sans', sans-serif; font-size:1em; line-height:1.5em;}
@jimmy89Li
jimmy89Li / header.php
Created August 3, 2016 09:46
Check for site icon. If none, add manually from template folder.
<link rel="shortcut icon" href="<?php wp_site_icon(); ?>" />
<link rel="shortcut icon" href="<?php bloginfo('template_url'); ?>/favicon.ico" />