Skip to content

Instantly share code, notes, and snippets.

View timkinnane's full-sized avatar

Tim Kinnane timkinnane

View GitHub Profile
@timkinnane
timkinnane / shortcode.php
Created April 7, 2013 23:36
Wordpress shortcode example
<?php
// MyShortcode usage [myshortcode greeting="Hello" who="World"]
function myshortcode_func( $atts, $content = null ) {
// use given attributes or defined defaults
extract( shortcode_atts( array(
'greeting' => '',
'who' => ''
), $atts ) );
@timkinnane
timkinnane / wp_update_url.sql
Created April 7, 2013 23:36
Wordpress, find and replace url in database.
UPDATE wp_options SET option_value = REPLACE (option_value, 'http://oldurl','http://newurl');
UPDATE wp_posts SET guid = REPLACE (guid,'http://orldurl','http://newurl');
# Change "wp_" to your database's table prefix
# Change oldurl, newurl (oldurl is the one in the database already)
@timkinnane
timkinnane / wp_install.sh
Created April 7, 2013 23:36
Wordpress, install via ssh
# First connect to host via SSH - cd to public_html or httpdocs
# Download latest WP to host (zip or tar.gz)
wget http://wordpress.org/latest.tar.gz
# Extract it
tar xzvf latest.tar.gz
# Move it out of 'wordpress' directory
mv wordpress/* ~/public_html
@timkinnane
timkinnane / wp_insert_admin.sql
Created November 19, 2012 05:02
Wordpress, insert admin user to database
# Adds a user and gives admin permissions to Wordpress database
# Change db_wordpress to DB name
# Change wp_ to your table prefix
# Change username, pass, nicename, email, url, displayname and pass to your new user info
# Change date to whenever you want the registered date to be
INSERT INTO `db_wordpress`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES (NULL, 'username', MD5('pass'), 'nicename', 'email', 'url', '2010-10-08 00:00:00', '', '0', 'displayname');
# Find the userid that was just created (int)