Skip to content

Instantly share code, notes, and snippets.

@nielsenrc
nielsenrc / wordpress-output-include-in-a-shortcode.php
Last active September 17, 2015 19:30
Wordpress | How to Output a PHP Include in a Shortcode
<?php
ob_start();
include ‘file.php';
$output = ob_get_clean();
$output = str_replace(array("\r", "\n"), '', $output);
return $output;
?>
@nielsenrc
nielsenrc / google-publisher-and-authorship-tags.html
Last active September 17, 2015 15:23
Google | Publisher and Authorship Tags
<link href="" rel="publisher">
<link rel="author" href="" />
@nielsenrc
nielsenrc / wordpress-next-and-previous-posts.php
Created September 10, 2015 14:43
Wordpress | Next and Previous Posts Links
<?php next_posts_link('Older Posts'); ?>
<?php previous_posts_link('Newer Posts'); ?>
@nielsenrc
nielsenrc / wordpress-live-sweep.sql
Created September 10, 2015 14:39
Wordpress | Change URL in Wordpress Database During Domain Change
// turn privacy setting off in Wordpress
UPDATE wp_options SET option_value = "1" WHERE option_name = "blog_public";
//change home and siteurl values
UPDATE wp_options SET option_value = "http://www.domain2.com" WHERE option_name = "home";
UPDATE wp_options SET option_value = "http://www.domain2.com" WHERE option_name = "siteurl";
// sweep options, post_content, and guid for references to old url
UPDATE wp_options SET option_value = REPLACE(option_value,'www.domain1.com','www.domain2.com');
UPDATE wp_posts SET post_content = REPLACE(post_content,'www.domain1.com','www.domain2.com');
UPDATE wp_posts SET guid = REPLACE(guid,'www.domain1.com','www.domain2.com');
@nielsenrc
nielsenrc / html-tel-tag.html
Created September 9, 2015 20:56
HTML | Tel Tag
<a href="tel:1-555-555-5555">1-555-555-5555</a>
@nielsenrc
nielsenrc / mysql-cms-made-simple-find-replace.sql
Last active September 9, 2015 20:22
MySQL | CMS Made Simple | Content Find and Replace
UPDATE cms_content_props SET content = REPLACE(content,'find','replace');
@nielsenrc
nielsenrc / wordpress-no-index-paginated-pages.php
Created September 9, 2015 20:21
Wordpress | Add no index to paginated pages
<?php if ( is_paged() ) { ?>
<meta name="robots" content="noindex,follow" />
<?php } ?>
@nielsenrc
nielsenrc / wordopress-create-virtual-file-in-plugin.php
Created September 9, 2015 20:10
Wordpress | Create Virtual File in Wordpress Plugin
<?php
//assumes you have a locations.php file in your plugin folder
function advnap_kml() {
$url = str_replace( trailingslashit( site_url() ), '', plugins_url( '/locations.php', __FILE__ ) );
add_rewrite_rule( 'locations\\.kml$', $url, 'top' );
}
add_action( 'wp_loaded', 'advnap_kml' );
function advnap_plugin_activate() {
flush_rewrite_rules();
@nielsenrc
nielsenrc / cli-search-for-files-containing-string.txt
Created September 9, 2015 19:50
CLI | Search for Files Containing String
grep -lr "text-you-are-searching-for" .
@nielsenrc
nielsenrc / mysql-dump-single-table.txt
Created September 9, 2015 19:49
MySQL | Dump a Single Table at Command Line
mysqldump db_name table_name > table_name.sql