All · Bootstrap · Google Analytics · Sage · Uncategorised · Wordpress

Use default thumbnail if no featured image

<?php if ( has_post_thumbnail() ) { ?>
 <?php the_post_thumbnail('thumbnail'); ?>
<?php } else { ?>
<img width="150" height="150" alt="post-thumb" class="attachment-thumbnail wp-post-image" src="<?php echo get_stylesheet_directory_uri(); ?>/assets/img/default-thumb.jpg">
 <?php }; ?>

Multi except lengths

//change excerpt length
 add_filter('excerpt_length', 'my_excerpt_length');
 function my_excerpt_length($length) {
 if (is_home()){
 return 25;
 else {
 return 50;

Echo site URL

<?php echo get_site_url(); ?>

Get parent page title

 $parent_title = get_the_title($post->post_parent);
 echo $parent_title;

Add onload tag function

 function my_places_add_to_body_load($template) {
 if ( is_page(array ('store-results' ) ) ) {
 ob_start('myplaces_load_js');  // Start Page Buffer
 return $template;
 function myplaces_load_js($buffer) {
 return str_replace('<body','<body onload="load()"',$buffer);

Useful WordPress tutorials and resources


WordPress theme tutorial:–wp-33987

Guide to custom post types (required for almost every site):–wp-27898

Featured images:

Custom post image slider:

Portfolio Tutorial:–wp-20565

Widget Area:

HTML to WordPress theme tutorial:

Installing WordPress locally

Install WordPress locally with XAMPP:

Install WordPress locally with MAMP:


Roots bootstrap theme (we use this for every site):

Advanced custom fields:

ACF repeater field:

ACF gallery field:

ACF options page:

ACF contact form 7 field:

ACF JQuery date picker field:

Contact form 7: