Skip to content

Instantly share code, notes, and snippets.

View bhubbard's full-sized avatar
:octocat:
Hello

Brandon Hubbard bhubbard

:octocat:
Hello
View GitHub Profile
<?php if( function_exists( 'wpseo_local_show_address' ) ) { wpseo_local_show_address( array( 'echo' => 'true' ) ); } ?>
<?php
// // Can be used in any (template) file, will do the same as shortcode [wpseo_address]
if( function_exists( 'wpseo_local_show_address' ) ) {
$params = array(
'echo' => true,
'id' => 237,
'show_state' => true,
'show_country' => true,
<?php require_if_theme_supports( 'super-seo', trailingslashit( TEMPLATEPATH ) . 'super-seo.php' ); ?>
@bhubbard
bhubbard / gist:c197a86e8786e7da9a91
Created March 9, 2015 16:45
Center Twitter Bootstrap Navbar
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
@bhubbard
bhubbard / gist:62feb556e3806d56cb2d
Created March 9, 2015 17:25
Wordpress loop of all custom post types and posts
/*
Loop thru all Custom Post Types
foreach( get_post_types( array('public' => true) ) as $post_type ) {
if ( in_array( $post_type, array('post','page','attachment') ) )
continue;
$pt = get_post_type_object( $post_type );
echo '<div class="row sitemap-section"> <div class="col-sm-12">';
echo '<h4>'.$pt->labels->name.'</h4>';
public static function get_country_array() {
$countries = array(
'AF' => __( 'Afghanistan', 'yoast-local-seo' ),
'AL' => __( 'Albania', 'yoast-local-seo' ),
'DZ' => __( 'Algeria', 'yoast-local-seo' ),
'AS' => __( 'American Samoa', 'yoast-local-seo' ),
'AD' => __( 'Andorra', 'yoast-local-seo' ),
'AO' => __( 'Angola', 'yoast-local-seo' ),
'AI' => __( 'Anguilla', 'yoast-local-seo' ),
'AQ' => __( 'Antarctica', 'yoast-local-seo' ),
<a class="houzz-share-button"
data-url="http://www.yoursite.com/product/page/ "
data-hzid="Your HZID"
data-title="Product Title as it will be seen inside Houzz "
data-img="http://yoursite/path/to/product/image.jpg "
data-desc="Product description text "
data-category="Category keywords "
data-showcount="1 "
href="http://www.houzz.com">Houzz</a>
<script>(function(d,s,id){if(!d.getElementById(id)){var js=d.createElement(s);js.id=id;js.async=true;js.src="//platform.houzz.com/js/widgets.js?"+(new Date().getTime());var ss=d.getElementsByTagName(s)[0];ss.parentNode.insertBefore(js,ss);}})(document,"script","houzzwidget-js");</script>
@bhubbard
bhubbard / gist:fe85f9cdc1d7a43e4ae8
Created March 11, 2015 19:21
Schema for Featured Image
<?php the_post_thumbnail('post-thumbnail',array('itemprop'=>'image')); ?>
SELECT name, slug
FROM wp_terms
WHERE term_id
IN (
SELECT term_id
FROM wp_term_taxonomy
WHERE taxonomy='post_tag'
AND count='0'
);
@bhubbard
bhubbard / gist:584dfe7e3572c32a9e5b
Created March 12, 2015 21:00
Clean up your WordPress database from weird characters Encoding problems can be really painful. Instead of manually update all of your posts, here is a query that you can run in order to clean your database from weird characters.
UPDATE wp_posts SET post_content = REPLACE(post_content, '“', '“');
UPDATE wp_posts SET post_content = REPLACE(post_content, '”', '”');
UPDATE wp_posts SET post_content = REPLACE(post_content, '’', '’');
UPDATE wp_posts SET post_content = REPLACE(post_content, '‘', '‘');
UPDATE wp_posts SET post_content = REPLACE(post_content, '—', '–');
UPDATE wp_posts SET post_content = REPLACE(post_content, '–', '—');
UPDATE wp_posts SET post_content = REPLACE(post_content, '•', '-');
UPDATE wp_posts SET post_content = REPLACE(post_content, '…', '…');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '“', '“');
@bhubbard
bhubbard / gist:c2cad006d453de012d1c
Created March 12, 2015 21:01
hange author attribution on all posts at once Do you need to change author attribution on many posts? If yes, you don’t have to do it manually. Here’s a handy query to do the job for you. The first thing to do is getting the IDs of WordPress users. Once logged in phpmyadmin, insert the following SQL command:
SELECT ID, display_name FROM wp_users;
UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID;