CODEBASE

Page Title

<title>
 <?php 
 if (function_exists('is_tag') && is_tag()) { 
 single_tag_title("Tag Archive for &quot;"); echo '&quot; - '; } 
 elseif (is_archive()) { 
 wp_title(''); echo ' Archive - '; } 
 elseif (is_search()) { 
 echo 'Search for &quot;'.wp_specialchars($s).'&quot; - '; } 
 elseif (!(is_404()) && (is_single()) || (is_page())) { 
 wp_title(''); echo ' - '; } 
 elseif (is_404()) { 
 echo 'Not Found - '; } 
 if (is_home()) { 
 bloginfo('name'); echo ' - '; bloginfo('description'); } 
 else {
 bloginfo('name'); }
 if ($paged>1) { 
 echo ' - page '. $paged; } 
 ?>
</title>

Bloginfo

<?php bloginfo('template_directory'); ?>

admin_email = admin@example.com
atom_url = http://www.example.com/home/feed/atom
charset = UTF-8
comments_atom_url = http://www.example.com/home/comments/feed/atom
comments_rss2_url = http://www.example.com/home/comments/feed
description = Just another WordPress blog
home = http://www.example.com/home (DEPRECATED! use url option instead)
html_type = text/html
language = en-US
name = Testpilot
pingback_url = http://www.example.com/home/wp/xmlrpc.php
rdf_url = http://www.example.com/home/feed/rdf
rss2_url = http://www.example.com/home/feed
rss_url = http://www.example.com/home/feed/rss
siteurl = http://www.example.com/home (DEPRECATED! use url option instead)
stylesheet_directory = http://www.example.com/home/wp/wp-content/themes/largo
stylesheet_url = http://www.example.com/home/wp/wp-content/themes/largo/style.css
template_directory = http://www.example.com/home/wp/wp-content/themes/largo
template_url = http://www.example.com/home/wp/wp-content/themes/largo
text_direction = ltr
url = http://www.example.com/home
version = 3.5
wpurl = http://www.example.com/home/wp

The Loop

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

Title

 <?php the_title(); ?>

Single Cat Title

<?php single_cat_title( '', true ); ?>

Add Post Thumbs / Image Size

add_theme_support( 'post-thumbnails' );
add_image_size( 'article0', 625, 395, true );

Get Post Thumbnail

if ( has_post_thumbnail() ) {
   the_post_thumbnail('thumbnail', array('class' => 'alignleft'));
}

Register Menus

register_nav_menus( array(
 'main_menu' => __( 'Main Menu', 'joytv' ), // Main site menu
 'secondary_menu' => __( 'Secondary Menu', 'joytv' ) // Main site menu
 ));

Nav Menu

<?php wp_nav_menu( array( 'menu' => 'Navigation', 'sort_column' => 'menu_order' ) ); ?>

Dynamic Sidebar

<?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar') ) : ?><?php endif; ?>

Get Header/Footer/Sidebar

<?php get_header(); ?>
<?php get_footer(); ?>
<?php get_sidebar(); ?>

Fix Excerpt

function new_excerpt_length($length) {
 return 15;
 }
 add_filter('excerpt_length', 'new_excerpt_length');
 
 function replace_excerpt($content) {
 return str_replace('[&hellip;]','...', $content);
 }
 add_filter('the_excerpt', 'replace_excerpt');

ACF: Field

<?$php if ( get_field('field_name') ) : ?>
  <?$php echo get_field('field_name'); ?>
<?$php endif; ?>

ACF: Repeater

<?php if ( have_rows('field_name') ) : ?>

  <?php while( have_rows('field_name') ) : the_row(); ?>

    <?php the_sub_field('sub_field_name'); ?>

  <?php endfor; ?>

<?php endif; ?>

ACF: Image

<?php if ( get_field('field_name') ) : ?>
    <img src="<?php the_field('field_name'); ?>" alt="<?php the_field(''); ?>">
<?php endif; ?>

ACF: Custom Query

<?php

$args = array(
  'numberposts' => 10,
  'post_type' => 'post',
  'meta_key' => 'field_name',
  'meta_value' => 'field_value'
);

$query = new WP_Query( $args );

?>

<?php if( $query->have_posts() ) : ?>
  <ul>
  <?php while ( $query->have_posts() ) : $query->the_post(); ?>
    <li>
      <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </li>
  <?php endwhile; ?>
  </ul>
<?php endif; ?>

<?php wp_reset_query(); ?>

ACF: Option Pages

// Add Options Panels
 if( function_exists('acf_add_options_page') ) {
 
 acf_add_options_page(array(
 'page_title' => 'Theme General Settings',
 'menu_title' => 'Theme Settings',
 'menu_slug' => 'theme-general-settings',
 'capability' => 'edit_posts',
 'redirect' => false
 ));
 
 acf_add_options_sub_page(array(
 'page_title' => 'Theme Homepage Settings',
 'menu_title' => 'Homepage',
 'parent_slug' => 'theme-general-settings',
 ));
 
 acf_add_options_sub_page(array(
 'page_title' => 'Theme Footer Settings',
 'menu_title' => 'Footer',
 'parent_slug' => 'theme-general-settings',
 ));
 
 }

Social Links (External)

// bookmark on Delicious
<a rel="nofollow" href="http://delicious.com/post?url=<?php the_permalink(); ?>&amp;title=<?php echo urlencode(get_the_title($id)); ?>" title="Bookmark this post at Delicious">Bookmark at Delicious</a>

// submit to Digg
<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=<?php the_permalink(); ?>" title="Submit this post to Digg">Digg this!</a>

// tweet on Twitter
<a rel="nofollow" href="http://twitter.com/home?status=<?php echo urlencode("Currently reading: "); ?><?php the_permalink(); ?>" title="Share this article with your Twitter followers">Tweet this!</a>

// submit to StumbleUpon
<a rel="nofollow" href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post at StumbleUpon">Stumble this!</a>

// share on Facebook
<a rel="nofollow" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&amp;t=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Facebook">Share on Facebook</a>

// submit to Blinklist
<a rel="nofollow" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;url=<?php the_permalink(); ?>&amp;Title=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Blinklist" >Blink This!</a>

// store on Furl
<a rel="nofollow" href="http://furl.net/storeIt.jsp?t=<?php echo urlencode(get_the_title($id)); ?>&amp;u=<?php the_permalink(); ?>" title="Share this post on Furl">Furl This!</a>

// submit to Reddit
<a rel="nofollow" href="http://reddit.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Reddit">Share on Reddit</a>

Social Links (Bit.ly Enhanced)

// in functions.php
function bitly()
 {
 //login information
 $url = get_permalink(); //for wordpress permalink
 $login = 'pantso'; //your bit.ly login
 $apikey = 'R_77e7977766a54493bc61cba400ea961d'; //add your bit.ly API
 $format = 'json'; //choose between json or xml
 $version = '2.0.1';
 //generate the URL
 $bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$apikey.'&format='.$format;
 
 //fetch url
 $response = file_get_contents($bitly);
 //for json formating
 if(strtolower($format) == 'json')
 {
 $json = @json_decode($response,true);
 return $json['results'][$url]['shortUrl'];
 }
 else //for xml formatting
 {
 $xml = simplexml_load_string($response);
 return 'http://bit.ly/'.$xml->results->nodeKeyVal->hash;
 }
 }
 
 function socialShares($medium) {
 
 $bitLink = bitly();
 
 if($medium == 'facebook') {
 return 'https://www.facebook.com/sharer/sharer.php?u='. $bitLink;
 }
 
 if($medium == 'twitter') {
 return 'https://twitter.com/intent/tweet?text='. get_the_title() .'&amp;url='. $bitLink .'&amp;via=voxelgr';
 }
 
 if($medium == 'google') {
 return 'https://plus.google.com/share?url='. $bitLink;
 }
 
 if($medium == 'reddit') {
 return 'http://www.reddit.com/submit?url='. $bitLink;
 }
 
 }

// in template
<ul class="social shares">
 <li><a class="soctop fb-bg" href="<?php echo socialShares('facebook'); ?>"><i class="vx-facebook-alt"></i><span>FACEBOOK</span></a></li>
 <li><a class="soctop tw-bg" href="<?php echo socialShares('twitter'); ?>"><i class="vx-twitter"></i><span>TWITTER</span></a></li>
 <li><a class="soctop gp-bg" href="<?php echo socialShares('google'); ?>"><i class="vx-google"></i><span>GPLUS</span></a></li>
 <li><a class="soctop re-bg" href="<?php echo socialShares('reddit'); ?>"><i class="vx-reddit"></i><span>REDDIT</span></a></li>
 </ul>

// in common.js
$('.shares a').on('click',function(e){
 e.preventDefault();
 var url = $(this).attr('href')
 window.open(url, "name", "scrollbars=1,width=500,height=400");
 });

Post Revisions

define('WP_POST_REVISIONS', 5);
define('WP_POST_REVISIONS', false);

Register Sidebar

if ( function_exists('register_sidebar') )
 register_sidebar(array(
 'before_widget' => '<aside>',
 'after_widget' => '</aside>',
 'before_title' => '<h1>',
 'after_title' => '</h1>',
));

Remove Admin BAr

add_filter( 'show_admin_bar', '__return_false' );

Hide WP Version

remove_action('wp_head', 'wp_generator');

Disable the theme / plugin text editor in Admin

define('DISALLOW_FILE_EDIT', true);

Hide Pages From Admin & Admin Bar

function remove_admin_menus(){
 if(is_user_logged_in() && !current_user_can('administrator')){
 remove_menu_page( 'index.php' ); //Dashboard
 remove_menu_page( 'edit.php' ); //Posts
 remove_menu_page( 'upload.php' ); //Media
 remove_menu_page( 'edit.php?post_type=page' ); //Pages
 remove_menu_page( 'edit-comments.php' ); //Comments
 remove_menu_page( 'themes.php' ); //Appearance
 remove_menu_page( 'plugins.php' ); //Plugins
 remove_menu_page( 'users.php' ); //Users
 remove_menu_page( 'tools.php' ); //Tools
 remove_menu_page( 'options-general.php' ); //Settings
 }
}
add_action('admin_init', 'remove_admin_menus');

function remove_admin_bar_links() {
 global $wp_admin_bar;
 if (!current_user_can('administrator')) {
 $wp_admin_bar->remove_menu('wp-logo'); // Remove the WordPress logo
 $wp_admin_bar->remove_menu('about'); // Remove the about WordPress link
 $wp_admin_bar->remove_menu('wporg'); // Remove the WordPress.org link
 $wp_admin_bar->remove_menu('documentation'); // Remove the WordPress documentation link
 $wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link
 $wp_admin_bar->remove_menu('feedback'); // Remove the feedback link
 $wp_admin_bar->remove_menu('site-name'); // Remove the site name link
 $wp_admin_bar->remove_menu('view-site'); // Remove the visit site link
 $wp_admin_bar->remove_menu('updates'); // Remove the updates link
 $wp_admin_bar->remove_menu('comments'); // Remove the comments link
 $wp_admin_bar->remove_menu('new-content'); // Remove the new content link
 $wp_admin_bar->remove_menu('my-account'); // Remove the user details tab
 }
}
add_action('wp_before_admin_bar_render', 'remove_admin_bar_links');