Skip to content

Instantly share code, notes, and snippets.

View jubalm's full-sized avatar

Jubal Mabaquiao jubalm

  • Iloilo, Philippines
View GitHub Profile
@jubalm
jubalm / functions.php
Created April 12, 2012 11:02
Useful Wordpress Functions
<?php
// Useful Shortcodes
add_shortcode('home_url', 'return_home_url');
add_filter('widget_text', 'do_shortcode'); // enable shortcodes on widgets
function return_home_url() {
return home_url();
}
add_shortcode('theme_url', 'return_theme_url');
function return_theme_url() {
@jubalm
jubalm / clearonfocus.js
Created April 27, 2012 08:00
jQuery clear on focus
// Clear Form on Focus
$('#search input[type="text"]').each(function() {
var default_value = this.value;
$(this).focus(function() {
if(this.value == default_value) {
this.value = '';
}
});
$(this).blur(function() {
if(this.value == '') {
@jubalm
jubalm / functions.php
Created April 30, 2012 02:27
wordpress - useful shortcodes
<?php
// Useful Shortcodes
add_shortcode('home_url', 'return_home_url');
add_filter('widget_text', 'do_shortcode'); // enable shortcodes on widgets
function return_home_url() {
return home_url();
}
add_shortcode('theme_url', 'return_theme_url');
function return_theme_url() {
return get_bloginfo('template_url');
@jubalm
jubalm / functions.php
Created April 30, 2012 02:30
wordpress - register sidebar
<?php
// Register Sidebar
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'before_widget' => '<div class="widget"',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
'name' =>'General Sidebar'
'id' =>'general-sidebar'
@jubalm
jubalm / functions.php
Created April 30, 2012 02:36
wordpress - custom post type
<?php
// Add custom post type
add_action( 'init', 'create_custom_post_type' );
function create_custom_post_type() {
register_post_type( 'custom_post',
array(
'labels' => array(
'name' => __( 'Custom Posts' ),
'singular_name' => __( 'Custom Post' )
),
@jubalm
jubalm / functions.php
Created April 30, 2012 02:43
wordpress - custom login style
<?php
// Modify Logo URL
add_filter( 'login_headerurl', 'login_page_url');
function login_page_url(){
return home_url();
}
// Modify Login Title
add_filter( 'login_headertitle', 'login_page_title');
function login_page_title(){
@jubalm
jubalm / functions.php
Created April 30, 2012 02:50
wordpress - enqueue scripts ( and styles )
<?php
// Enqueue Styles and Scripts
add_action('wp_enqueue_scripts', 'load_styles_and_scripts');
function load_styles_and_scripts()
{
wp_enqueue_style( 'style', get_bloginfo('template_directory') . '/css/theme.css' );
wp_enqueue_script( 'script', get_bloginfo('template_directory') . '/js/script.css', 'jquery', '1.7', false );
}
?>
@jubalm
jubalm / config.fancybox.js
Created April 30, 2012 02:52
wordpress - fancybox
jQuery(function ($) {
$('.gallery .gallery-item a').attr('rel', 'fancybox').fancybox();
})
@jubalm
jubalm / sidebar-excerpts.php
Created April 30, 2012 07:37
wordpress - custom pages section
<div class="secton" id="services">
<div class="container">
<?php
$count = 0;
$slugs = array('page1', 'page2', 'page3');
$pages_array = array();
foreach ($slugs as $slug) {
$page = get_page_by_path($slug);
array_push($pages_array, $page->ID);
@jubalm
jubalm / functions.php
Created May 12, 2012 04:40
wordpress - remove default gallery styles
<?php
// remove default gallery styles
add_filter('gallery_style', create_function('$a', 'return "<div class=\'gallery\'>";'));
?>